如何在同一视图上设置多个布局,以便它们均匀共享空间?同样在父布局中设置多个视图/布局
以下网址有我的要求图像:
的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