【发布时间】:2014-11-20 21:23:00
【问题描述】:
可视化 XML:http://imgur.com/AgGoVy0
我有一个在相对布局内具有线性布局的 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>
【问题讨论】: