安卓XML布局,相對布局的常用屬性~


RelativeLayout布局
android:layout_marginTop="25dip" //頂部距離
android:gravity="left" //空間布局位置
android:layout_marginLeft="15dip //距離左邊距


// 相對於給定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   右偏移的值;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM