ImageView经常用到宽度填满屏幕,高度自适应的效果。但试验了所有的scaleType都没有这种效果。找了半天发现这样可以实现,而且绝对是最简单的一种方式:
<ImageView
android:id="@+id/iv_pic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@mipmap/enterprise" />
重点是: android:scaleType="fitXY"
android:adjustViewBounds="true" 配合使用
本文介绍了一种简单的方法来实现ImageView宽度填满屏幕且高度自适应的效果。通过设置`android:scaleType=fitXY`及`android:adjustViewBounds=true`, 可以使图片在保持宽高比的同时,完美填充屏幕。
6830

被折叠的 条评论
为什么被折叠?



