Android RelativeLayout属性大全

// 相对于给定ID控件

android:layout_above 将该控件的底部置于给定ID的控件之上;

android:layout_below 将该控件的底部置于给定ID的控件之下;

android:layout_toLeftOf 将该控件的右边缘与给定ID的控件左边缘对齐;

android:layout_toRightOf 将该控件的左边缘与给定ID的控件右边缘对齐;


android:layout_alignBaseline 将该控件的baseline与给定ID的baseline对齐;

android:layout_alignTop 将该控件的顶部边缘与给定ID的顶部边缘对齐;

android:layout_alignBottom 将该控件的底部边缘与给定ID的底部边缘对齐;

android:layout_alignLeft 将该控件的左边缘与给定ID的左边缘对齐;

android:layout_alignRight 将该控件的右边缘与给定ID的右边缘对齐;

// 相对于父组件

android:layout_alignParentTop 如果为true,将该控件的顶部与其父控件的顶部对齐;

android:layout_alignParentBottom 如果为true,将该控件的底部与其父控件的底部对齐;

android:layout_alignParentLeft 如果为true,将该控件的左部与其父控件的左部对齐;

android:layout_alignParentRight 如果为true,将该控件的右部与其父控件的右部对齐;

// 居中

android:layout_centerHorizontal 如果为true,将该控件的置于水平居中;

android:layout_centerVertical 如果为true,将该控件的置于垂直居中;

android:layout_centerInParent 如果为true,将该控件的置于父控件的中央;

// 指定移动像素

android:layout_marginTop 上偏移的值;

android:layout_marginBottom 下偏移的值;

android:layout_marginLeft 左偏移的值;

android:layout_marginRight 右偏移的值;





android:layout_toRightOf="@+id/XX" //当前视图的左边与XX的右边靠在一起
android:layout_above
android:layout_below
android:layout_toLeftOf


android:padding="5px" //
android:paddingLeft="15.0sp" //当前视图的内部填充物(文字、图片等)距离当前视图的左边框15sp






android:layout_marginLeft="5.0px" //当前视图的左边框与它左边的视图距离5.0px
android:layout_marginRight="5.0px"
android:layout_marginBottom="5.0px" //底部
android:layout_marginTop="5.0px"


example:

android:layout_below = "@id/***"

android:layout_alignBaseline = "@id/***"

android:layout_alignParentTop = true

android:layout_marginLeft = “10px”







/*------------------------------------------我是分割线---------------------------------------------------------------------------------------*/




android:id —— 为控件指定相应的ID
android:text —— 指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串
android:textSize —— 指定控件当中字体的大小
android:background —— 指定该控件所使用的背景色,RGB命名法 #FFFFFF或@android:color/white
android:width —— 指定控件的宽度
android:height

—— 指定控件的高度
android:sigleLine —— 如果设置为真的话,则将控件的内容只能在同一行当中进行显示

android:grivity —— 指定控件中的内容的基本位置,比如说居中,居右等位置
android:layout_gravity 控件本身相对于父视图的位置


//此属性值为带单位的数值 在所有视图中都可使用
android:padding —— 指定控件的四周的内部留出一定的空间
android:paddingLeft —— 指定控件的左边的内部留出一定的空间
android:paddingTop —— 指定控件的上边的内部留出一定的空间
android:paddingRight —— 指定控件的右边的内部留出一定的空间
android:paddingBottom —— 指定控件的下边的内部留出一定的空间


//此属性值为带单位的数值 在所有视图中都可使用
android:layout_margin—— 指定控件的四周的外部留出一定的空间
android:layout_marginLeft—— 指定控件的左边的外部留出一定的空间
android:layout_marginTop—— 指定控件的上边的外部留出一定的空间
android:layout_marginRight—— 指定控件的右边的外部留出一定的空间
android:layout_marginBottom—— 指定控件的下边的外部留出一定的空间


//此属性值为引用id 只能在相对布局中都可使用
android:layout_above 将该控件的底部与给定ID的控件之上部对齐
android:layout_below 将该控件的上部与给定ID的控件之下部对齐
android:layout_toLeftOf 将该控件的右与给定ID的控件之左边对齐
android:layout_toRightOf 将该控件的左边与给定ID的控件的右边对齐


//此属性值为引用id 只能在相对布局中都可使用
android:layout_alignTop 将该控件的上部与给定ID的控件之上部对齐
android:layout_alignBottom 将该控件的下部与给定ID的控件之下部对齐
android:layout_alignLeft 将该控件的左与给定ID的控件之左边对齐
android:layout_alignRight 将该控件的右边与给定ID的控件的右边对齐
android:layout_alignBaseline 该控件的baseline和给定ID的控件的baseline对齐

//此属性值为引用id 只能在相对布局中都可使用
android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐
android:layout_alignParentLeft 如果该值为true,则将该控件的左边与父控件的左边对齐
android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐
android:layout_alignParentTop 如果该值为true,则将空间的顶部与父控件的顶部对齐


android:layout_centerHorizontal 如果值为真,该控件将被至于水平方向的中央
android:layout_centerInParent 如果值为真,该控件将被至于父控件水平方向和垂直方向的中央
android:layout_centerVertical 如果值为真,该控件将被至于垂直方向的中央


中,所有元件都是按由上到下的排队排成的
-->





相关文档
最新文档