public static void setViewHeight(Context context, View target, float scale) {
ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
layoutParams.height = (int) (getScreenHeight(context) * scale);
target.setLayoutParams(layoutParams);
}
public static void setViewWidth(Context context, View target, float scale) {
ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
layoutParams.width = (int) (getScreenWidth(context) * scale);
target.setLayoutParams(layoutParams);
}
//使用,参数二为控件
setViewHeight(context, mViewTopBg, 0.6f);