Android ImageView中的图像比例为3:2
列表视图中显示了许多图像 我的列表\u视图\u item.xml(ivEventImage中的图像):Android ImageView中的图像比例为3:2,android,listview,imageview,Android,Listview,Imageview,列表视图中显示了许多图像 我的列表\u视图\u item.xml(ivEventImage中的图像): 它们有不同的尺寸-640 x 480、1280 x 720、1920 x1080、1080x1920和其他尺寸。除了不同的尺寸,不同的方向-纵向或横向。 并且所有图像都具有不同的纵横比 如何在ImageView中显示图像,但纵横比为3:2,如果图像高度不适合仅显示图像的中间部分。但不打破比例 黑色正方形-ivEventImage。 左-1280x720,右-1080x1920(例如)。
它们有不同的尺寸-640 x 480、1280 x 720、1920 x1080、1080x1920和其他尺寸。除了不同的尺寸,不同的方向-纵向或横向。
并且所有图像都具有不同的纵横比
如何在ImageView中显示图像,但纵横比为3:2,如果图像高度不适合仅显示图像的中间部分。但不打破比例
黑色正方形-ivEventImage。
左-1280x720,右-1080x1920(例如)。
对于
android:scaleType
使用centerCrop
而不是fitXY
,如下所示
android:scaleType="centerCrop"
因此,ImageView
xml将
<ImageView
android:id="@+id/ivEventImage"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@null"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/ivEventImage"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@null"
android:layout_width="match_parent"
android:layout_height="match_parent" />