`
cenphoenix
  • 浏览: 158796 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

RelativeLayout

阅读更多

RelativeLayout顾名思义就是根据各个控件之间的关系进行布局

和容器间的关系:
android:layout_alignParentTop

says the widget's top should align with the top of the container


android:layout_alignParentBottom

says the widget's bottom should align with the bottom of the container


android:layout_alignParentLeft

says the widget's left side should align with the left side of the container


android:layout_alignParentRight

 says the widget's right side should align with the right side of the container


android:layout_centerHorizontal

says the widget should be positioned horizontally at the center of the container


android:layout_centerVertical

says the widget should be positioned vertically at the center of the container


android:layout_centerInParent

says the widget should be positioned both horizontally and vertically at the center of the container

 

以上各个属性的值都为boolean值类型

当你需要引用另外一个控件的属性值时,可通过@id/widget_a.property进行引用

 

和其他控件间的关系:

android:layout_above

indicates that the widget should be placed above the widget referenced in the property


android:layout_below

indicates that the widget should be placed below the widget referenced in the property


android:layout_toLeft

indicates that the widget should be placed to the left of the widget referenced in the property


android:layout_toRight

 indicates that the widget should be placed to the right of the widget referenced in the property

 

android:layout_alignTop

 indicates that the widget's top should be aligned with the top of the widget referenced in the property


android:layout_alignBottom

indicates that the widget's bottom should be aligned with the bottom of the widget referenced in the
property


android:layout_alignLeft

indicates that the widget's left should be aligned with the left of the widget referenced in the property


android:layout_alignRight

 indicates that the widget's right should be aligned with the right of the widget referenced in the property


android:layout_alignBaseline

indicates that the baselines of the two widgets should be aligned

 

假如我们需要将控件B放在控件A的右边,我们可以这样进行设置

在控件B上写上:android:layout_toRight ="@id/widget_a"

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics