【发布时间】:2018-05-29 20:41:11
【问题描述】:
我正在做一个项目,我想在一个页面中创建两个部分,例如,我将使用给定的部分创建一个主页(下面的 xml 代码)。这将在main_activity.xml 文件上完成,我想将底部LinearLayout 的视图设置为不同的布局资源文件。其中将包含一些不同的代码。我怎样才能做到这一点?
<RelativeLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
<LinearLayout>
android:id="@+id/Top"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
</LinearLayout>
<LinearLayout>
android:id="@+id/Bottom"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
</LinearLayout>
</RelativeLayout/>
【问题讨论】:
-
不明白你想用你的底部布局做什么
-
首先:不确定您的示例中的布局权重是否正常工作...考虑使用带有权重和的 LinearLayout,使用垂直的 android:orientation... 然后,在下面制作您的线性布局,高度为 0dp,以便重量按您的意愿工作 :)...其次:查看
控件,它使您能够包含您制作的布局,而不是您正在使用的 LinearLayout现在。干杯!
标签: android xml android-layout android-linearlayout