现在的位置: 首页 > 综合 > 正文

Android中有关布局的几个问题

2013年04月15日 ⁄ 综合 ⁄ 共 542字 ⁄ 字号 评论关闭

1.android:gravity和android:layout_gravity区别

  android:gravity

Specifies how to place the content of an object, both
on the x- and y-axis, within the object itself.

  android:layout_gravity

Standard gravity constant that a child can supply to its parent.


从名字上可以看到,android:gravity是对元素本身说的,元素本身的文本显示在什么地方靠着换个属性设置,不过不设置默认是在左侧的。android:layout_gravity是相对与它的父元素说的,说明元素显示在父元素的什么位置。


note:这两个属性不容易掌握,可是作用又很大(设置控件位置时候),建议多尝试。


2.当LinearLayout的layout_oritentation设置为horizontal ,并且里面的控件使用了layout_width="fill_parent"
,第二组控件会挡在屏幕的右边,那也就是看不到了。这种情况应该避免,建议里面的控件使用layout_width="wrap_content'或者指定具体的像素值。

抱歉!评论已关闭.