Android FrameLayout
FrameLayout ,以堆疊方式呈現加入的元件,後加入的元件會覆蓋前面的元件,所有加入的子元件的起始點皆為 FrameLayout 的左上角,無法像 LinearLayout 做垂直及水平排列,也無法像 RelativeLayout 有能相對佈局的屬性。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >
<TextView android:layout_width="match_parent" android:layout_height="20dp" android:background="#0000ff" android:text="Test1" android:textColor="#ffffff" android:textAlignment="viewEnd"/>
<TextView android:layout_width="200dp" android:layout_height="20dp" android:background="#00ff00" android:text="Test2" android:textColor="#ffffff" android:textAlignment="viewEnd"/>
<TextView android:layout_width="100dp" android:layout_height="20dp" android:background="#ff0000" android:text="Test3" android:textColor="#ffffff" /> </FrameLayout>
|
常用屬性 :
android:foreground
:設置 FrameLayout 的前景圖像。
android:foregroundGravity
: 定義繪製前景圖像的gravity屬性,即前景圖像的顯示位置。