LinearLayout 属性详解
来源:互联网 发布:还珠之知画重生之乾隆 编辑:程序博客网 时间:2024/06/01 10:23
LinearLayout 属性详解
转自:http://m.blog.csdn.net/article/details?id=50135175
四个极其重要的参数,直接决定元素的布局和位置
android:layout_gravity 本元素相对于父元素的重力方向
android:gravity 本元素所有子元素的重力方向
android:orientation 线性布局以列或行来显示内部子元素
android:layout_weight 子元素对未占用空间水平或垂直分配权重值
当 android:orientation="vertical" 时, 只有水平方向的设置才起作用,垂直方向的设置不起作用。即:left,right,center_horizontal 是生效的。!!!!
当 android:orientation="horizontal" 时, 只有垂直方向的设置才起作用,水平方向的设置不起作用。即:top,bottom,center_vertical 是生效的。!!!!
android:layout_gravity 和 android:gravity 的区别
android:gravity对元素本身起作用-本身元素显示在什么位置
android:layout_gravity相对与它的父元素-元素显示在父元素的什么位置。
如:Button控件
android:layout_gravity 表示button在界面上的位置
android:gravity表示button上的字在button上的位置。
可选值[多选时用“|”分开]
top、bottom、left、right、center_vertical、fill_vertical、center_horizontal、fill_horizontal、center、fill、clip_vertical。
top 将对象放在其容器的顶部,不改变其大小.
bottom 将对象放在其容器的底部,不改变其大小.
left将对象放在其容器的左侧,不改变其大小.
right将对象放在其容器的右侧,不改变其大小.
center_vertical 将对象纵向居中,不改变其大小.
垂直对齐方式:垂直方向上居中对齐。
fill_vertical 必要的时候增加对象的纵向大小,以完全充满其容器. 垂直方向填充
center_horizontal 将对象横向居中,不改变其大小水平对齐方式:水平方向上居中对齐
fill_horizontal 必要的时候增加对象的横向大小,以完全充满其容器. 水平方向填充
center 将对象横纵居中,不改变其大小.
fill 必要的时候增加对象的横纵向大小,以完全充满其容器.
clip_vertical 附加选项,用于按照容器的边来剪切对象的顶部和/或底部的内容. 剪切基于其纵向对齐设置:顶部对齐时,剪切底部;底部对齐时剪切顶部;除此之外剪切顶部和底部.垂直方向裁剪
clip_horizontal 附加选项,用于按照容器的边来剪切对象的左侧和/或右侧的内容. 剪切基于其横向对齐设置:左侧对齐时,剪切右侧;右侧对齐时剪切左侧;除此之外剪切左侧和右侧.水平方向裁剪
例子
TextView要让文本垂直/水平居中显示,有两种情况需要考虑:
1、layout_width/layout_height为wrap_content,此时要让TextView在父控件上居中显示,必须设置layout_gravity=”center”。
2、layout_width/layout_height为fill_parent,此时由于TextView已占据父窗体所有空间,必须设置gravity=”center”。
- LinearLayout 属性详解
- LinearLayout 属性详解
- LinearLayout 属性详解
- LinearLayout 属性详解
- LinearLayout中的layout_weight属性详解
- android(LinearLayout)属性详解
- Android布局-LinearLayout属性详解
- LinearLayout详解
- linearlayout详解
- LinearLayout的andrid:layout_weight属性的使用详解
- LinearLayout的andrid:layout_weight属性的使用详解
- 日积月累:LinearLayout的andrid:layout_weight属性的使用详解
- LinearLayout的andrid:layout_weight属性的使用详解
- Android中LinearLayout布局的Weight属性详解
- Android gravity属性详解(注:此属性是linearlayout的属性)
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- 总结 mysql + mybatis的 mapper中对应关系
- 论文PCANet: A Simple Deep Learning Baseline for Image Classification?的matlab源码解读(二)
- 【业界偷懒】【Public】BZOJ题目一句话题解整理
- 浅谈如何学习linux(强烈推荐)
- CC150 2.8&&Linked List Cycle dection 判断循环LinkedList
- LinearLayout 属性详解
- tomcat性能优化
- About RNN
- HDU1576 解方程....
- 今日学习——const 变量申明 volatitle static
- google Guava包的ListenableFuture解析
- fork bomb
- 解决集成百度自动更新SDK和360自动更新SDK上传市场审核失败的坑
- js高级程序设计