標籤:android blog http io ar 2014 on log 代碼
幀布局由FrameLayout所代表,FrameLayout直接繼承了ViewGoup組件。
幀版面配置容器為每個加入其中的組件建立一個空白的地區(稱為一個幀),每個子組件佔據一幀,這些幀都會根據gravity屬性執行自動對齊。
代碼:
<?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" android:orientation="vertical" > <!-- 依次定義6個TextView,先定義的TextView位於底層 後定義的TextView位於上層 --><TextView android:id="@+id/view01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="320px" android:height="320px" android:background="#f00" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="280px" android:height="280px" android:background="#0f0" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="240px" android:height="240px" android:background="#00f" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="200px" android:height="200px" android:background="#ff0" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="160px" android:height="160px" android:background="#f0f" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="120px" android:height="120px" android:background="#0ff" /></FrameLayout>
效果:
Android中的FrameLayout幀布局