码迷,mamicode.com
首页 > 其他好文 > 详细

RelativeLayout中的格局,自适应宽度布局

时间:2016-01-22 03:02:31      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

RelativeLayout中的布局,自适应宽度布局

技术分享


该图片中为android布局:
总布局为 RelativeLayout
AtLeft 为居左 
<TextView android:background="#ff0000ff" android:id="@+id/tvwAtLeft"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="AtLeft" android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"$amp;>amp;$lt;/TextView>

AtRight为居右
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_alignParentTop="true"
android:layout_alignParentRight="true" android:id="@+id/tvwAtRight"
android:text="AtRight" android:background="#ff0000ff"$amp;>amp;$lt;/TextView>

Scroll为中间的布局 
<TextView android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_toRightOf="@+id/tvwAtLeft"
android:layout_width="fill_parent" android:id="@+id/tvwScrolling"
android:layout_toLeftOf="@+id/tvwAtRight" android:text="Scrolling"
android:background="#FFFF0000"$amp;>amp;$lt;/TextView>

在中间的布局设置了android:layout_width="fill_parent" 
android:layout_toRightOf="@+id/tvwAtLeft"
android:layout_toRightOf="@+id/tvwAtLeft"
三个属性后,那么将会有类似于LinearLayout布局中的layout_weight="1"(大于0的值)一样的效果,宽度进行了自适应
经我测试,红色的2个属于貌似不用设置,也是一样效果的。

RelativeLayout中的格局,自适应宽度布局

标签:

原文地址:http://www.cnblogs.com/qing123/p/5150073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!