20 按比例设置 子控件的宽度和高度

1.得到当前屏幕的 分辨率

Display display = this.getWindowManager().getDefaultDisplay();
int totalWidth = display.getWidth();
int totalHeight = display.getHeight();

2.设置高度和宽度

ImageView curView = (ImageView)layout.findViewById(R.id.imageView1);
LayoutParams para = curView.getLayoutParams();
para.height = (int)(totalWidth * 0.8);
para.width = (int)(totalWidth * 0.8);
curView.setLayoutParams(para);

原文地址:https://www.cnblogs.com/xl711436/p/3130163.html