android relativelayout属性总结

来源:互联网 发布:淘宝质量好的男装推荐 编辑:程序博客网 时间:2024/05/08 22:05

------------指定偏移量

1.android:paddingleft(paddingright/paddingtop/paddingbottom):控件内部内容(如文本距离该控件的边距);

2.android:paddingstart(paddingend):左右对齐时使用。左对齐时:paddingstart对应paddingleft;paddingend对应paddingright;右对齐时则刚好相反;

3.android:layout_margin:该控件距离父控件的边距;(layout_marginleft/layout_marginright/layout_margintop/layout_marginbottom);


------------给定控件ID

4.android:layout_above :将该控件的底部至于给定ID的控件之上;

5.android:layout_below :将该控件的顶部至于给定ID的控件之下;

6.android:layout_toLeftOf :将该控件的右边缘和给定ID的控件的左边缘对齐;

7. android:layout_toRightOf:将该控件的左边缘和给定ID的控件的右边缘对齐;

8.android:layout_alignBaseline: 该控件的baseline和给定ID的控件的baseline对齐;(baseline为控件的基准线);

   关于基线的含义参考另一篇博文:http://blog.csdn.net/hanyingjie327/article/details/22799811

9.android:layout_alignBottom:将该控件的底部边缘与给定ID控件的底部边缘对齐;

10. android:layout_alignLeft:将该控件的左边缘与给定ID控件的左边缘对齐;

11.android:layout_alignRight :将该控件的右边缘与给定ID控件的右边缘对齐;

12.android:layout_alignTop : 将给定控件的顶部边缘与给定ID控件的顶部对齐;


------------相对于父组件

13.android:alignParentBottom :如果该值为true,则将该控件的底部和父控件的底部对齐;

14.android:layout_alignParentLeft:如果该值为true,则将该控件的左边与父控件的左边对齐;

15.android:layout_alignParentRight :如果该值为true,则将该控件的右边与父控件的右边对齐;

16.android:layout_alignParentTop:如果该值为true,则将空间的顶部与父控件的顶部对齐;

17.android:layout_alignWithParentIfMissing 如果对应的兄弟元素找不到的话就以父元素做参照物;


------------居中

18.android:layout_centerHorizontal :如果值为真,该控件将被至于水平方向的中央;

19.android:layout_centerInParent:如果值为真,该控件将被至于父控件水平方向和垂直方向的中央;

20.android:layout_centerVertical: 如果值为真,该控件将被至于垂直方向的中央;


------------外部间隔

android:layout_marginTop       上偏移的值;

android:layout_marginBottom  下偏移的值;

android:layout_marginLeft   左偏移的值;

android:layout_marginRight   右偏移的值;


------------其它

21.android:gravity:设置容器中的内容的位置,默认为靠左;

22.android:layout_gravity:设置容器中内容相对于容器的位置(无法在relativelayout中使用);


注意:不能在RelativeLayout容器本身和他的子元素之间产生循环依赖,比如说,不能将RelativeLayout的高设置成为WRAP_CONTENT的时候将子元素的高设置成为ALIGN_PARENT_BOTTOM。



转自:http://blog.csdn.net/kimifdw/article/details/11981509

参考:http://www.open-open.com/lib/view/open1371351481250.html

0 0