RelativeLayout和LinearLayout的属性
来源:互联网 发布:淘宝开通直播间 编辑:程序博客网 时间:2024/04/29 22:30
LinearLayout和RelativeLayout
共有属性:
在<LinearLayout>(or RelativeLayout)中共有的属性
java代码中通过btn1关联次控件
android:id="@+id/btn1"
控件宽度
android:layout_width="80px" //"80dip"或"80dp"
android:layout_width =“wrap_content”
android:layout_width =“match_parent”
控件高度
android:layout_height="80px" //"80dip"或"80dp"
android:layout_height =“wrap_content”
android:layout_height =“match_parent”
控件间距
android:layout_marginLeft="5dip" //距离左边
android:layout_marginRight="5dip" //距离右边
android:layout_marginTop="5dip" //距离上面
android:layout_marginRight="5dip" //距离下面
控件显示位置
android:gravity="center" //left,right, top, bottom
android:gravity="center_horizontal"
定义控件是否可见
android:visibility=”visible” //可见
android:visibility=”invisible” //不可见,但是在布局中占用的位置还在
android:visibility=”gone” //不可见,完全从布局中消失
在<LinearLayout>(or RelativeLayout)中的子控件中的共有的属性
控件显示位置
android:layout_gravity是本元素对父元素的重力方向。
android:layout_gravity属性则设置控件本身相对于父控件的显示位置
android:gravity是本元素所有子元素的重力方向。
android:layout_gravity="center_vertical"
android:layout_gravity="left"
android:layout_gravity="left|bottom"
仅在RelativeLayout中的子控件里面的属性有效:
在父亲布局的相对位置
android:layout_alignParentLeft="true" //在布局左边
android:layout_alignParentRight="true" //在布局右边
android:layout_alignParentTop="true" //在布局上面
android:layout_alignParentBottom="true " //在布局的下面
在某个控件的相对位置
android:layout_toRightOf="@id/button1" //在控件button1的右边,不仅仅是紧靠着
android:layout_toLeftOf="@id/button1" //在控件button2的左边,不仅仅是紧靠着
android:layout_below="@id/button1 " //在控件button1下面,不仅仅是正下方
android:layout_above=“@id/button1” //在控件button1下面,不仅仅是正下方
定义和某控件对齐
android:layout_alignTop=”@id/button1” //和控件button1上对齐
android:layout_alignBottom=”@id/button1” //和控件button1下对齐
android:layout_alignLeft=”@id/button1” //和控件button1左对齐
android:layout_alignRight=”@id/button1” //和控件button2右对齐
android:layout_centerHorizontal="true" //水平居中
android:layout_centerVertical="true"
android:layout_centerInParent="true"
仅在LinearLayout中的子控件里面的属性有效
设置控件在一排或一列中所占比例值
android:layout_weight="1"
仅在LinearLayout中的属性有效
控件排布
android:orientation="horizontal”
android:orientation="vertical“
转自:http://www.blogjava.net/zhip/archive/2011/01/25/343511.html
- RelativeLayout和LinearLayout的属性
- LinearLayout和RelativeLayout 属性
- linearLayout 和 relativeLayout的属性区别
- LinearLayout 和 RelativeLayout的属性对比
- linearLayout 和 relativeLayout的属性区别
- linearLayout 和 relativeLayout的属性区别
- LinearLayout和RelativeLayout的属性差异
- linearLayout 和 relativeLayout的属性区别
- linearLayout 和 relativeLayout的属性区别(转)
- 【转】linearLayout 和 relativeLayout的属性区别
- LinearLayout和RelativeLayout的特殊属性
- linearLayout 和 relativeLayout的属性区别
- LinearLayout和RelativeLayout的常见属性
- LinearLayout和RelativeLayout 属性对比
- LinearLayout和RelativeLayout 属性对比
- LinearLayout和RelativeLayout 属性对比
- LinearLayout和RelativeLayout 属性对比
- LinearLayout和RelativeLayout 属性对比
- [BetterExplained]如何有效地记忆与学习
- Table td下用rowspan的一二问题
- Mybatis使用经验分享之批量操作
- 【Android学习之道】 拍照后Bitmap图片模糊或者缩小的问题解决
- nodejs+express实现文件上传
- RelativeLayout和LinearLayout的属性
- iOS 之应用性能调优的25个建议和技巧
- ADO.Net基础
- Kafka入门经典教程
- ADO.Net连接
- linux理论知识
- 名校家教-android 多渠道包分发
- Android广播机制Broadcast详解
- 关于指针的引用的讲解