`
天天向上1989
  • 浏览: 411710 次
  • 性别: Icon_minigender_2
  • 来自: 南京
社区版块
存档分类
最新评论

【转】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);

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics