<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src ="@drawable/timg2"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:maxHeight="300dp"
/>
原图
ImageView的scaleType的属性有matrix(默认)、centerCrop、centerInside、center、fitCenter、fitEnd、fitStart、fitXY 依次如下:
注意 src 和scaleType要一起 adjustViewBounds 保持宽高比