概述
LinearLayout 应用在所放置的组件完全在一条直线上,要么是横向的要么是纵向的。
组件和组件之间没有复杂的位置关系,通过 orientation 设置方向(横向/纵向);通过 gravity 设置对齐方式。
一、参考网址(推荐看原文)
http://developer.android.com/reference/android/widget/LinearLayout.html
http://developer.android.com/guide/topics/ui/layout/linear.html
二、继承关系
三、主要属性和方法
android:gravity
Specifies how an object should position its content, on both the X and Y axes, within its own bounds.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
top | 0x30 | 不改变组件大小,对齐到容器顶部 |
bottom | 0x50 | 不改变组件大小,对齐到容器底部 |
left | 0x03 | 不改变组件大小,对齐到容器左侧 |
right | 0x05 | 不改变组件大小,对齐到容器右侧 |
center_vertical | 0x10 | 不改变组件大小,对齐到容器纵向的中央位置 |
fill_vertical | 0x70 | 若有可能,纵向拉伸组件以填满容器 |
center_horizontal | 0x01 | 不改变组件大小,对齐到容器横向中央位置 |
fill_horizontal | 0x07 | 若有可能,横向拉伸组件以填满容器 |
center | 0x11 | 不改变组件大小,对齐到容器中央位置 |
fill | 0x77 | 若有可能,纵向横向同时拉伸组件以填满容器 |
start | 0x00800003 | 不改变组件大小,把组件放到容器的最开始 |
end | 0x00800005 | 不改变组件大小,把组件放到容器的最结尾 |
This corresponds to the global attribute resource symbol gravity
.
Related Methods
- setGravity(int)
android:orientation
Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column. The default is horizontal.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
horizontal | 0 | Defines an horizontal widget. |
vertical | 1 | Defines a vertical widget. |
This corresponds to the global attribute resource symbol orientation
.
Related Methods
- setOrientation(int)
最后
以上就是坚定诺言为你收集整理的android LinearLayout 的适用场景和基本属性的全部内容,希望文章能够帮你解决android LinearLayout 的适用场景和基本属性所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复