Android在多个版面上更改背景色

Android在多个版面上更改背景色,android,android-layout,Android,Android Layout,可视XML: 我有一个xml,在一个相对布局中有一个线性布局。我有一个自定义的背景画,可以设置背景的颜色。然而,我希望主菜单有一个紫色的主体,它位于白色的相对布局父菜单之上。如何将紫色布局堆叠在白色布局之上 编辑:我通过删除主父相对布局上的背景色,然后在自定义可绘制背景菜单中设置紫色来修复它 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schem

可视XML:

我有一个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=".Welcome" 
android:background="#694489"
android:gravity="center">

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:orientation="vertical" 
    android:background="@drawable/custom_background_menu"
    android:layout_gravity="center"
    >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="30dp"
            android:text="PATHING GAME"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="20dp" 
            android:gravity="center"/>

            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/buttontype"
                android:text="START"
                android:layout_margin="20dp" />

                <Button
                    android:id="@+id/button2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/buttontype"
                    android:text="HOW TO PLAY"
                    android:layout_margin="20dp" />

                                    <Button
                    android:id="@+id/button3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/buttontype"
                    android:text="EXIT" 
                    android:layout_margin="20dp"/>

</LinearLayout>



</RelativeLayout>
移动

android:background="@drawable/custom_background_menu"
添加到将位于linearLayout1后面的ImageView,以便主相对论Layout将有两个子项,即新的ImageView和现有的linearLayout1。然后将紫色背景移动到linearLayout1,如下所示:

<RelativeLayout ...>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/custom_background_menu"/>

    <LinearLayout ...
        android:background="#694489" />

</RelativeLayout>
看看这是否有帮助