我是靠谱客的博主 坚定诺言,最近开发中收集的这篇文章主要介绍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

  • 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.

ConstantValueDescription
horizontal0Defines an horizontal widget.
vertical1Defines a vertical widget.

This corresponds to the global attribute resource symbol orientation.

Related Methods
  • setOrientation(int)

最后

以上就是坚定诺言为你收集整理的android LinearLayout 的适用场景和基本属性的全部内容,希望文章能够帮你解决android LinearLayout 的适用场景和基本属性所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部