我創建了一個線性佈局,並添加了兩個相對佈局。我希望在底部的另一個佈局中顯示一個佈局。我的問題是佈局顯示在頂部。如何更改1layout頂部另一個是底部請幫助我。如何在底部顯示相對佈局?
XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/blue"
android:orientation="horizontal" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="55px"
android:background="@drawable/testheader"
android:orientation="horizontal" >
<TextView
android:id="@+id/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="settings"
android:textColor="@color/white"
android:textSize="20sp" />
<Button
android:id="@+id/btnReturn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="image" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="55px"
android:background="@drawable/testheader"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
>
<Button
android:id="@+id/btnReturn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Return" />
</RelativeLayout>
</LinearLayout>
更改您的LinearLayout到RelativeLayout的。 –