Android:2个相对布局分为半屏 [英] Android: 2 relative layout divided in half screen
本文介绍了Android:2个相对布局分为半屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了很多次绘制 2 个相对布局水平对齐并分成半屏.
I tried many times to draw 2 Relative layout aligned horizontally and divided in half screen.
我用油漆设计图像是为了更好地解释我的意思.
I design the image with paint to explain a bit better what i mean.
有什么建议吗?
推荐答案
您可以将这 2 个 RelativeLayouts 放在一个水平方向的 LinearLayout 中,然后使用 权重.这会将 LinearLayout 分成 2 个相等的部分.
You can put these 2 RelativeLayouts inside a LinearLayout with horizontal orientation, then use the weight for both RelativeLayouts. This will divide the LinearLayout in 2 equal parts.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
这篇关于Android:2个相对布局分为半屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文