两个分屏 [英] Split screen in two
本文介绍了两个分屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将它拆分我的布局分为两个halves.When我尝试layout_weight,在被分为两个水平halves.How做我分裂成布局两个垂直半。
<?XML版本=1.0编码=UTF-8&GT?;
机器人:ID =@ + ID / linearLayout123的android:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_weight =1
机器人:layout_gravity =顶
机器人:ID =@ + ID / linearLayout12
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
<按钮机器人:ID =@ + ID /按钮1
机器人:layout_width =WRAP_CONTENT 机器人:layout_height =WRAP_CONTENT
机器人:文字=你好,我是一个按钮/> < / LinearLayout中><的LinearLayout机器人:layout_weight =1
机器人:layout_gravity =底机器人:ID =@ + ID / linearLayout1
机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT>
<的TextView
机器人:ID =@ + ID /文本2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=您好,我是一个TextView/> < / LinearLayout中> < / LinearLayout中>
解决方案
使用'方向=纵在封闭设计,并应用权重的孩子,如:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_gravity =补
机器人:layout_height =FILL_PARENT
机器人:layout_width =FILL_PARENT
机器人:weightSum =1.0
机器人:方向=垂直
机器人:填充=5DP>< TopChildView机器人:layout_height =0dp
机器人:layout_weight =0.5
... />< BottomChildView机器人:layout_height =0dp
机器人:layout_weight =0.5
... />
I am trying to split my layout into two halves.When I try layout_weight,in splits it into two horizontal halves.How do i split the layout into two vertical halves.
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/linearLayout123" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="1"
android:layout_gravity="top"
android:id="@+id/linearLayout12"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</LinearLayout>
<LinearLayout android:layout_weight="1"
android:layout_gravity="bottom" android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
</LinearLayout>
</LinearLayout>
解决方案
Use 'orientation="vertical"' in the enclosing layout, and apply your weights to the children such as:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="fill"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:weightSum="1.0"
android:orientation="vertical"
android:padding="5dp">
<TopChildView android:layout_height="0dp"
android:layout_weight="0.5"
.../>
<BottomChildView android:layout_height="0dp"
android:layout_weight="0.5"
.../>
这篇关于两个分屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文