【发布时间】:2014-11-19 10:01:32
【问题描述】:
我有一个充满整个屏幕的片段。现在,如果我添加一个新片段,我希望每个片段都占据屏幕的一半。我该怎么做?
我尝试了这种布局并以编程方式添加了片段。但它不起作用。
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="tech.test.org.game.Game$PlaceholderFragment">
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="50">
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_below="@+id/relativeLayout"
android:layout_weight="50"
>
</RelativeLayout>
</RelativeLayout>
谢谢。
【问题讨论】:
标签: android android-layout android-fragments android-xml