【转】android ImageView 宽度设定,高度自适应

http://www.cnblogs.com/bcbr/articles/4268276.html

需求是,imageview 宽度充满屏幕,高度自适应

首先,需要给你的ImageView 

imageView.setAdjustViewBounds(true);

imageView.setScaleType(ScaleType.FIT_XY);

LayoutParams params = new LayoutParams(screenWidth, LayoutParams.WRAP_CONTENT);

imageView.setLayoutParams(params);

设置了setMaxWidth setMaxHeightsetAdjustViewBounds才有效

imageView.setMaxWidth(screenWidth);

imageView.setMaxHeight(screenWidth * 10);

猜你喜欢

转载自daydayup1989.iteye.com/blog/2248706
今日推荐