Android 如何删除版面和背景之间的空间?

Android 如何删除版面和背景之间的空间?,android,android-layout,Android,Android Layout,我有一个相对布局,其中包含另外两个相对布局,每个布局都有图像,我将每个图像作为其相对布局的背景,但我仍然可以看到图像、布局和整个父布局之间的空间。。那么我怎样才能删除这个空间?? 这是我的XML代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_w

我有一个相对布局,其中包含另外两个相对布局,每个布局都有图像,我将每个图像作为其相对布局的背景,但我仍然可以看到图像、布局和整个父布局之间的空间。。那么我怎样才能删除这个空间?? 这是我的XML代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

        <RelativeLayout
            android:id="@+id/relative1"
            android:layout_width="match_parent"
            android:layout_height="150sp"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:background="@drawable/upper" >
    </RelativeLayout>

            <RelativeLayout
                android:id="@+id/relative2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/relative1"
                android:background="@drawable/down" >

     <ListView
         android:id="@+id/listView1"
         android:layout_width="wrap_content"
         android:layout_height="280dp"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true" >

    </ListView>    
    </RelativeLayout>
    </RelativeLayout>

如何解决此问题?

删除顶层布局中的填充内容

删除主RelativeLayout中的所有填充属性

试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

        <RelativeLayout
            android:id="@+id/relative1"
            android:layout_width="match_parent"
            android:layout_height="150sp"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:background="@drawable/upper" >
        </RelativeLayout>

        <RelativeLayout
                android:id="@+id/relative2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/relative1"
                android:background="@drawable/down" >

        <ListView
         android:id="@+id/listView1"
         android:layout_width="wrap_content"
         android:layout_height="280dp"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true" >


       </ListView>    
     </RelativeLayout>
</RelativeLayout>

这可能有助于您将相对布局定义为:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
只要把它们去掉,你就没事了

你想要什么:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >

认真地你有这个怀疑吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >