Android的ImageView如何maxHeight与maxWidth生效
16lz
2021-01-26
ImageView有一个属性设置:adjustViewBounds,其值默认为false,
若没有设置成true,则当ImageView的Height/Width设置成wrap_content时,则maxHeight, maxWidth都将不起作用。
正确的设置方法如下:
<ImageView android:layout_width="match_parent" android:adjustViewBounds="true" android:layout_height="wrap_content" android:maxHeight="250dp" android:scaleType="fitStart" android:src="@drawable/test_img" />
这样,当图片高度大于250dp时,会缩放到250dp的高度。
更多相关文章
- 【转】Eclipse 开发Android小程序遇到的问题总结
- android之RadioButton与RadioGroup,CheckBox,switch,ToggleButton
- Android判断app是否后台运行中,后台运行通知栏提示
- android中画廊视图Gallery和ImageSwitcher组件的使用
- Android(安卓)Universal-Iamge-Loader的DisplayImageOptions
- 【Android】 设置App字体不跟随系统字体改变
- android 系统 makefile文件(Android.mk)组织结构
- Android之使用PopupWindow使用和总结
- android之绘图工具类详解