android LinearLayout 的适用场景和基本属性


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.

ConstantValueDescription
top0x30不改变组件大小,对齐到容器顶部
bottom0x50不改变组件大小,对齐到容器底部
left0x03不改变组件大小,对齐到容器左侧
right0x05不改变组件大小,对齐到容器右侧
center_vertical0x10不改变组件大小,对齐到容器纵向的中央位置
fill_vertical0x70若有可能,纵向拉伸组件以填满容器
center_horizontal0x01不改变组件大小,对齐到容器横向中央位置
fill_horizontal0x07若有可能,横向拉伸组件以填满容器
center0x11不改变组件大小,对齐到容器中央位置
fill0x77若有可能,纵向横向同时拉伸组件以填满容器
start0x00800003不改变组件大小,把组件放到容器的最开始
end0x00800005不改变组件大小,把组件放到容器的最结尾
  

This corresponds to the global attribute resource symbol gravity.
Related Methods


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.

ConstantValueDescription
horizontal0Defines an horizontal widget.
vertical1Defines a vertical widget.

This corresponds to the global attribute resource symbol orientation.

Related Methods

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值