潇潇洒洒

 

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);

 

 

posted on 2013-06-09 22:37  肖磊  阅读(173)  评论(0编辑  收藏  举报

导航