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" 配合使用