我试图设置一个屏幕的一部分,其中4个图像彼此相邻,但根据图像示例,它们之间有巨大的空白区域:
我希望他们能够彼此相邻.下面是我使用的XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:src="@drawable/test1"
android:layout_weight="1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:src="@drawable/test"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/imageView3"
android:src="@drawable/test1"
android:layout_weight="1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/imageView4"
android:src="@drawable/test"
android:layout_weight="1"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我也试图让他们到屏幕的顶部,但白色空间阻止了这一点.
你看到的图像根本没有任何空白区域,颜色的边缘是图像的边缘?
谢谢
你需要设置scaleTypeto centerInside和adjustViewBoundsto true这样:(调整视图边界应该摆脱你不想要的空间.)
<ImageView
...
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:adjustViewBounds="true" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
768 次 |
| 最近记录: |