這裏的XML代碼:兩個Relativelayouts縱向顯示
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Welcome"
android:layout_centerInParent="true" android:textSize="20sp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Welcome"
android:layout_centerInParent="true" android:textSize="20sp"/>
</RelativeLayout>
</RelativeLayout>
它不是一個真正的現場(用戶界面的設計是不是代碼,但我提出它爲了簡化)。 除了這段代碼之外,TextViews會相對於另一個顯示(以垂直方式)。像:
Welcome
Welcome
但不是輸出如下:
Welcome
一樣,他們是嵌套在一起,彼此堆疊。 我做了寬度佈局作爲填充父母,所以爲什麼其他佈局不下來?它會覆蓋第一個相關佈局。
我必須有2個佈局,所以請不要建議我只創建一個佈局。
謝謝。
優秀的,它的工作原理感謝的人! – idish
由於太早,不能接受你的回答,我會在10分鐘內接受它。 – idish