动态设置控件的宽高:

//先将50dp转化为px
            float dp = 50;
            final float scale = context.getResources().getDisplayMetrics().density;
            //由30dp转化来的px
            int px = (int) (dp * scale + 0.5f);
            //动态设置控件宽高
            ViewGroup.LayoutParams params = iv_icon.getLayoutParams();
            params.height = px;
            params.width = px;
            iv_icon.setLayoutParams(params);