如何在同一視圖上設置多個佈局,以便它們均勻共享空間?同樣在父佈局中設置多個視圖/佈局
以下網址有我的要求圖像:
的RelativeLayouts的How to set two different layouts for one view using constraints?
每個都鋪設了另一種。 請建議需要我當前XML這種情況的modificiation:
<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=".ScrollAct" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<RelativeLayout
android:id="@+id/rlExtendBar;"
android:layout_width="match_parent"
android:layout_height="?">
</RelativeLayout>
<RelativeLayout
android:id="@+id/rel_layout"
android:layout_width="match_parent"
android:layout_height="?">
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
嘿,感謝您的answer.Further,如果我們需要把水平分隔在說屏幕的2/3(在這種情況下,每個佈局花費2/3,1/3空間),應該做什麼修改? –
@LauraStone您可以將線性佈局作爲父佈局,將兩個線性佈局作爲孩子,並根據您的要求給予權重。 – Piyush
@LauraStone你必須使用weight屬性。在你的例子中,你必須爲第一個視圖設置layout_weight =「2」,爲第二個視圖設置「1」。總數將是3,第一次佔2/3,第三次佔三分之一。 – FR073N