DisplayMetrics dm = new DisplayMetrics();
//取得窗口属性
getWindowManager().getDefaultDisplay().getMetrics(dm);
//窗口的宽度
int screenWidth = dm.widthPixels;
ImageView mImageView = (ImageView)findViewById(R.id.login_icon); ViewGroup.LayoutParams lp = mImageView.getLayoutParams();
lp.width= screenWidth;
lp.height= RelativeLayout.LayoutParams.WRAP_CONTENT;
mImageView.setLayoutParams(lp);
mImageView.setMaxWidth(screenWidth);
mImageView.setMaxHeight(screenWidth* 5);
需要注意:
必须设置ImageView 的属性。 android:adjustViewBounds="true"

RelativeLayout 布局是指mImageView 所在上级布局 
售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款