Android:控件布局(相對布局)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----對齊到控件基准線

 

android:layout_above="@id/xxx"  --將控件置於給定ID控件之上
android:layout_below="@id/xxx"  --將控件置於給定ID控件之下

android:layout_toLeftOf="@id/xxx"  --將控件的右邊緣和給定ID控件的左邊緣對齊
android:layout_toRightOf="@id/xxx"  --將控件的左邊緣和給定ID控件的右邊緣對齊

android:layout_alignLeft="@id/xxx"  --將控件的左邊緣和給定ID控件的左邊緣對齊
android:layout_alignTop="@id/xxx"  --將控件的上邊緣和給定ID控件的上邊緣對齊
android:layout_alignRight="@id/xxx"  --將控件的右邊緣和給定ID控件的右邊緣對齊
android:layout_alignBottom="@id/xxx"  --將控件的底邊緣和給定ID控件的底邊緣對齊
android:layout_alignParentLeft="true"  --將控件的左邊緣和父控件的左邊緣對齊
android:layout_alignParentTop="true"  --將控件的上邊緣和父控件的上邊緣對齊
android:layout_alignParentRight="true"  --將控件的右邊緣和父控件的右邊緣對齊
android:layout_alignParentBottom="true" --將控件的底邊緣和父控件的底邊緣對齊
android:layout_centerInParent="true"  --將控件置於父控件的中心位置
android:layout_centerHorizontal="true"  --將控件置於水平方向的中心位置
android:layout_centerVertical="true"  --將控件置於垂直方向的中心位置

 

相對父容器,值是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---------------將控件對齊到父控件的尾部

 

android:layout_marginLeft指該控件距離邊父控件的邊距,

android:paddingLeft指該控件內部內容,如文本距離該控件的邊距。

 

來源:

http://blog.csdn.net/loongembedded/article/details/35569043

http://www.cnblogs.com/tinyphp/p/3787994.html

http://blog.csdn.net/softkexin/article/details/5933589/

http://www.cnblogs.com/yihujiu/p/5722088.html


免責聲明!

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



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