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"
更多相关文章
- android 自定义控件(邮箱边写边出格式邮箱)
- 自定义控件--虚线
- Android(安卓)自绘输入框
- android之4.0控件switch自定义开关滑块、滑块轨道和宽度
- Android中WebView控件的使用
- android 五种 布局文件
- Android(安卓)Studio 新建编辑条 点击按钮显示控件中的内容
- android 关于listview scrollview 底部 控件无法显示的两个解决
- Android(安卓)- Navigation