图像高度太高

时间:2015-07-31 07:32:55

标签: android xml

我正在尝试设置一个屏幕的一部分,每个图像周围有4个图像,但根据图像示例,它们之间有很大的空白区域:

example of problem

我希望他们能够彼此相邻。下面是我正在使用的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>

我也试图让他们到屏幕的顶部,但是空白区域阻止了这一点。

你看到的图像根本没有任何空白区域,颜色的边缘是图像的边缘?

由于

3 个答案:

答案 0 :(得分:6)

你需要将echo "The base circle area is : $a"; 设置为scaleType,将centerInside设置为adjustViewBounds,这样:(调整视图边界应该摆脱你不会占用的空间。我想要。)

true

答案 1 :(得分:2)

@ x10sion:有关您的信息,

为什么要添加此

android:scaleType="centerInside" 会将图像置于容器内部,而不是使边缘完全匹配。 Reference

android:adjustViewBounds="true" 如果您希望ImageView调整其边界以保持其drawable的宽高比,则为true。

答案 2 :(得分:1)

这:android:layout_height="wrap_content" 应该是这样的:android:layout_height="fill_parent"android:layout_height="match_parent",在你的四个ImageViews上。