1. 程式人生 > >Android中RelativeLayout各個屬性

Android中RelativeLayout各個屬性

對齊 ntop www. 邊緣 顯示 android ali www clas

Android中RelativeLayout各個屬性

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" --將控件置於垂直方向的中心位置

其中很重要的android:layout_alignParentLeft="true" --將控件的左邊緣和父控件的左邊緣對齊有時候找不到知道為啥?

那是因為你的父控件不是相對布局,當你的父控件是相對布局,子控件才能顯示這個屬性

轉自學步園https://www.xuebuyuan.com/2083533.html

Android中RelativeLayout各個屬性