一,android layout属性介绍:

Android有4种Layout:FrameLayout,LinearLayout,TableLayout,RelativeLayout。

放入Layout中进行排布的View的XML属性:
4种Layout中Item所共有的XML属性:
(1)layout_width
(2)layout_height
(3)layout_marginLeft
(4)layout_marginTop
(5)layout_marginRight
(6)layout_marginBottom
(7)layout_gravity

FrameLayout中的Item就具有这些属性。
对于LinearLayout还会有
(8)layout_weight

TableLayout的行TableRow是一个横向的(horizontal)的LinearLayout。

RelativeLayout有16个align相关的XML属性。
(9)layout_above
(10)layout_alignBaseline
(11)layout_alignBottom
(12)layout_alignLeft
(13)layout_alignParentBottom
(14)layout_alignParentLeft
(15)layout_alignParentRight
(16)layout_alignParentTop
(17)layout_alignRight
(18)layout_alignTop
(19)layout_below
(20)layout_centerHorizontal
(21)layout_centerInParent
(22)layout_centerVertical
(23)layout_toLeftOf
(24)layout_toRightOf

(1)和(2)用来确定放入Layout中的View的宽度和高度:它们的可能取值为fill_parent,wrap_content或者固定的像素值。
(3)(4)(5)(6)是放入Layout中的View期望它能够和Layout的边界或者其他View之间能够相距一段距离。
(7)用来确定View在Layout中的停靠位置。
(8)用于在LinearLayout中把所有子View排布之后的剩余空间按照它们的layout_weight分配给各个拥有这个属性的View。
(9)到(24)用来确定RelativeLayout中的View相对于Layout或者Layout中的其他View的位置。

二,layout_weight属性介绍

该属性一般都应用在LinearLayout中,在控件的layout_width值为fill_parent的时候,多个设置了wight属性的控件,weight的值越小,其站的控件越大。如果width值为

wrap_content,则weight的值越小,站的控件越就越小。

但是在width值为wrap_content的时候,首先要保证控件的显示,weight分配的空间是在除了控件wrap_content所占空间外剩余的空间里按比例分配的。


更多相关文章

  1. 【安卓】Android播放器的三种实现方法
  2. Android开发入门之学习笔记(四):程序窗口的布局(二)
  3. Android(安卓)菜单(Menu)控件的使用
  4. android程序在Layout中设置控件水平或垂直居中
  5. 安卓常用属性
  6. android:windowSoftInputMode属性使用
  7. 快速了解Android(安卓)onMeasure() onLayout()
  8. 3.1如何编写程序界面&3.2常见控件使用方法
  9. [android]控件EditText常用属性

随机推荐

  1. Android Studio瀵煎叆arr鍖咃紝鎶ラ敊鎵
  2. Android相对属性布局总结
  3. Android 多进程总结
  4. [转]Android 中自定义View的应用.
  5. 疯狂android讲义----android事件处理(1)
  6. Android(安卓)app\build\intermediates
  7. Android更改桌面应用程序launcher的两种
  8. Android的APP启动过程分析
  9. andriod环境的配置eclipse
  10. Android拍照、相册选取、裁剪图片综合Dem