[转] http://fancycoder.diandian.com/post/2013-09-23/40053396201
在Android布局的时候相信会经常遇到上述参数配置,下面我们就直接给出他们的区别:
-
gravity:表示组件内的文字的对齐方式;
-
layout_gravity:针对LinearLayout的一种组件对齐方式,可以把值设置成下列值:
center_vertical、center_horizontal、center等等
-
layout_centerHorizontal:是相对于RelativeLayout的布局属性,除此之外还有下列几项,有兴趣的可以到Android的官方参考文档去研究下:
android:layout_centerHorizontal -- If true, centers this child horizontally within its parent.
android:layout_centerInParent --If true, centers this child horizontally and vertically within its parent.
android:layout_centerVertical -- If true, centers this child vertically within its parent.