相对布局:layout_alignBottom和layout_above之间不同

时间:2013-11-10 14:38:28

标签: android android-layout relativelayout

我已经阅读了有关相对布局的这两个属性的文档,并尝试了一些示例,但仍然无法识别它们之间的区别。我已经尝试了一些测试,但我经常会得到相同的结果,有时候会有所不同,但我无法解释。

以下是Android文档中的说明:

android:layout_above
Positions the bottom edge of this view above the given anchor view ID. Accommodates bottom margin of this view and top margin of anchor view.

android:layout_alignBottom
Makes the bottom edge of this view match the bottom edge of the given anchor view ID. Accommodates bottom margin.

谢谢:)

3 个答案:

答案 0 :(得分:18)

此图片解释了所有内容:)

enter image description here

以上:视图的下边缘位于视图A的顶部边缘

alignBottom:视图的下边缘位于View B的同一行。

答案 1 :(得分:2)

android:layout_above

这个View的下边缘是引用View 顶部边缘的地方。

android:layout_alignBottom

View的下边缘是引用View 底部边缘的地方。

如果您想看到它的实际效果,我建议您向gravity="center"添加layout_gravity(不是RelativeLayout - 存在差异),因此第一个View会居中第二个是在第一个上面或同一个地方。使用android:layout_toRightOf使它们不重叠。

答案 2 :(得分:1)

android:layout_above :

在简单的登录页面中。用户ID编辑文本为layout_above到密码编辑文本。

android:layout_alignBottom

标签用户ID和用户ID编辑文字正在使用android:layout_alignBottom

相关问题