Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ImageView中的图像比例为3:2_Android_Listview_Imageview - Fatal编程技术网

Android ImageView中的图像比例为3:2

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(例如)。

列表视图中显示了许多图像

我的列表\u视图\u item.xml(ivEventImage中的图像):


它们有不同的尺寸-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" />