ImageView显示图像顶部和底部的空白区域

7 layout android imageview

我在android布局中添加图像.顶部和底部的图像中没有空白区域,但是当我在imageView中添加图像时,它会在图像的顶部和底部显示空白区域.因此,如果我想在图像和textview之间的图像空间下方立即添加textview.

我不明白为什么imageview在图像的顶部和底部显示空白区域.我没有添加任何类似的东西等android:padding.

  <ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/img1" />
Run Code Online (Sandbox Code Playgroud)

Kau*_*hik 22

将这些添加attributes到其中ImageView

android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="fitXY"
Run Code Online (Sandbox Code Playgroud)


Itz*_*ara 5

改成这个

   <ImageView
   android:id="@+id/imageView3"
   android:layout_width="wrap_content"
   android:layout_height="match_parent"
   android:layout_alignParentLeft="true"
   android:layout_alignParentTop="true"
   android:adjustViewBounds="true"
   android:scaleType="fitXY"
   android:src="@drawable/img1" />
Run Code Online (Sandbox Code Playgroud)