Android:控件布局(相对布局)RelativeLayout
2017-12-21 17:13
387 查看
RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列。
相对布局常用属性:
子类控件相对子类控件:值是另外一个控件的id
android:layout_above———-位于给定DI控件之上
android:layout_below ———-位于给定DI控件之下
android:layout_toLeftOf ——-位于给定控件左边
android:layout_toRightOf ——位于给定控件右边
android:layout_alignLeft ——-左边与给定ID控件的左边对齐
android:layout_alignRight ——右边与给定ID控件的右边对齐
android:layout_alignTop ——-上边与给定ID控件的上边对齐
android:layout_alignBottom —-底边与给定ID控件的底边对齐
android:layout_alignBaseline—-对齐到控件基准线
相对父容器,值是true或false
android:layout_alignParentLeft ——相对于父靠左
android:layout_alignParentTop——-相对于父靠上
android:layout_alignParentRight——相对于父靠右
android:layout_alignParentBottom —相对于父靠下
android:layout_centerInParent=”true” ——-相对于父即垂直又水平居中
android:layout_centerHorizontal=”true” —–相对于父即水平居中
android:layout_centerVertical=”true” ——–相对于父即处置居中
相对于父容器位置:
android:layout_margin=”10dp”
android:layout_marginLeft
android:layout_marginRight
android:layout_marginTop
android:layout_marginBottom
版本4.2以上相对布局新属性
android:layout_alignStart———————将控件对齐给定ID控件的头部
android:layout_alignEnd———————-将控件对齐给定ID控件的尾部
android:layout_alignParentStart————–将控件对齐到父控件的头部
android:layout_alignParentEnd—————将控件对齐到父控件的尾部
相对布局常用属性:
子类控件相对子类控件:值是另外一个控件的id
android:layout_above———-位于给定DI控件之上
android:layout_below ———-位于给定DI控件之下
android:layout_toLeftOf ——-位于给定控件左边
android:layout_toRightOf ——位于给定控件右边
android:layout_alignLeft ——-左边与给定ID控件的左边对齐
android:layout_alignRight ——右边与给定ID控件的右边对齐
android:layout_alignTop ——-上边与给定ID控件的上边对齐
android:layout_alignBottom —-底边与给定ID控件的底边对齐
android:layout_alignBaseline—-对齐到控件基准线
相对父容器,值是true或false
android:layout_alignParentLeft ——相对于父靠左
android:layout_alignParentTop——-相对于父靠上
android:layout_alignParentRight——相对于父靠右
android:layout_alignParentBottom —相对于父靠下
android:layout_centerInParent=”true” ——-相对于父即垂直又水平居中
android:layout_centerHorizontal=”true” —–相对于父即水平居中
android:layout_centerVertical=”true” ——–相对于父即处置居中
相对于父容器位置:
android:layout_margin=”10dp”
android:layout_marginLeft
android:layout_marginRight
android:layout_marginTop
android:layout_marginBottom
版本4.2以上相对布局新属性
android:layout_alignStart———————将控件对齐给定ID控件的头部
android:layout_alignEnd———————-将控件对齐给定ID控件的尾部
android:layout_alignParentStart————–将控件对齐到父控件的头部
android:layout_alignParentEnd—————将控件对齐到父控件的尾部
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/firstview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一文本" android:background="#ff0000" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第二文本" android:background="#ffff00" android:layout_toRightOf="@+id/firstview" /> </RelativeLayout>
相关文章推荐
- Android:控件布局(相对布局)RelativeLayout(转)
- 控件悬浮在某个控件之上 Android五大布局方式——相对布局(RelativeLayout)属性详解
- Android:控件布局(相对布局)RelativeLayout RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列。 相对布局常用属性: 子类控件相对子
- Android UI控件系列:RelativeLayout(相对布局)
- android 动态调整RelativeLayout布局控件的相对位置 layout_toLeftOf 之类的
- 第13章、布局Layouts之RelativeLayout相对布局(从零开始学Android)
- Android开发重点难点:RelativeLayout(相对布局)详解
- 再学习---Android相对布局(RelativeLayout)
- Android之RelativeLayout(相对布局)
- 关于android中的相对布局RelativeLayout
- Android开发视频教程之十一(Activity布局初步三:相对布局RelativeLayout)
- Android相对布局(RelativeLayout)
- Android布局RelativeLayout(相对布局)笔记
- Android RelativeLayout相对布局
- Android相对布局RelativeLayout属性说明
- 从头学Android之RelativeLayout相对布局
- Android入门之相对布局(RelativeLayout)
- Android RelativeLayout 相对布局解析
- Android布局---相对布局(Relative Layout)
- 相对布局(Relativelayout)——Mars Android开发视频之第一季第十三集(重)