[android]代码库
LayoutInflater inflater = LayoutInflater.from(getActivity());
layout = (LinearLayout) inflater .inflate(R.layout.qrcode_dialog, null);
LayoutParams pram = new LayoutParams(Util.getWindowWidth(mContext) / 5 * 4, LayoutParams.WRAP_CONTENT);
//下面的这行代码很关键
pram.width = Util.getWindowWidth(mContext) / 5 * 4;
layout.setLayoutParams(pram);
//获取屏幕的宽度,此处获取高度省略
public static int getWindowWidth(Context context) {
DisplayMetrics dm = context.getApplicationContext()
.getApplicationContext().getResources().getDisplayMetrics();
return dm.widthPixels;
}
by: 发表于:2018-01-02 10:01:35 顶(0) | 踩(0) 回复
??
回复评论