close
- FrameLayout
FrameLayout–框架佈局,可以算是佈局中最簡單的一種,佈局中的元件可以一個一個疊在一起,最先的元件會被放在最底而最後的元件會被放在最上面,簡單來說就像是疊羅漢一樣,譬如說在一個ImageView上放上一個Button,他不會因為不同元件的關係而分開顯示,而是會因為先後關係變成Button疊在Image之上,當然這也要看設計時將各元件擺放的位置及先後關係而定。
FrameLayout:
在這個範例中,因為沒有設定各元件擺放的位置,所以通通會集中在左上開始顯示,也因為通通都在左上開始顯示所以依序會是Image再來是Button最後Text在最上面。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="10dp"> <ImageView android:layout_width="200dp" android:layout_height="200dp" android:src="@drawable/homeview"/> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button"/> <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:text=" I am Text " android:textSize="25dp" android:textColor="#ffffff"/> </FrameLayout>
範例中的圖片出處:彈力小龍包
觀看其它種Layout:
全站熱搜