Android -- android activity 各种布局方式以及相关参数

来源:互联网 发布:我的小公主 知乎 编辑:程序博客网 时间:2024/05/01 05:16

转载:http://blog.sina.com.cn/s/blog_3fe740f40100nzs7.html
LinearLayout - 线形布局。
orientation - 容器内元素的排列方式。vertical: 子元素们垂直排列;horizontal: 子元素们水平排列
gravity - 内容的排列形式。常用的有 top, bottom, left, right, center 等

FrameLayout - 层叠式布局。以左上角为起点,将 FrameLayout 内的元素一层覆盖一层地显示
TableLayout - 表格式布局。
TableRow - 表格内的行,行内每一个元素算作一列
collapseColumns - 设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开
stretchColumns - 设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)的列的列索引,多个用“,”隔开
shrinkColumns - 设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开
RelativeLayout - 相对定位布局。
layout_centerInParent - 将当前元素放置到其容器内的水平方向和垂直方向的中央位置(类似的属性有 :layout_centerHorizontal, layout_alignParentLeft 等)
layout_marginLeft - 设置当前元素相对于其容器的左侧边缘的距离
layout_below - 放置当前元素到指定的元素的下面
layout_alignRight - 当前元素与指定的元素右对齐

layout_width - 宽。
fill_parent: 宽度跟着父元素走;
wrap_content: 宽度跟着本身的内容走;
直接指定一个 px 值来设置宽

layout_height - 高。
fill_parent: 高度跟着父元素走;
wrap_content: 高度跟着本身的内容走;
直接指定一个 px 值来设置高

0 0