![]() |
[Android UI 設計] [版面布局Layout介紹] FrameLayout |
這是一種可以提供類似浮動視窗的應用,通常都先選定FrameLayout顯示的區域之後,在其中置入圖片或一個獨立的「View」,也就是說將FrameLayout當作畫布(Canvas)使用,可是在FrameLayout中一次只能顯示一個子元件,若是加入其它元件只會被堆放到後面看不到。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#adc"
android:orientation="vertical" >
<EditText
android:id="@+id/editText1"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_toLeftOf="@+id/button1"
android:text="CheckBox" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText1"
android:layout_below="@+id/editText1"
android:text="Button" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="@drawable/main" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="FrameLayout"
android:textAppearance="?android:attr/textAppearanceLarge" />
<FrameLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignRight="@+id/imageView1"
android:layout_alignTop="@+id/imageView1" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/images" />
</FrameLayout>
</RelativeLayout>
![[Android UI 設計] [版面布局Layout介紹] FrameLayout [Android UI 設計] [版面布局Layout介紹] FrameLayout](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbh5v-VbrsT2XNVLdqDmW4Nx1rEPTY5H4O5v29W4ucqKO3Uf1Gp7pQc6WCUKxtOJp9JEUzZlI51xLLwZ1vYpcNoCFiXrTRj3Qxc2rb8kPOtkCKyqsfIhKWTIjJH2fBbk2guGAO14al30o/s1600/Snap7.png)
沒有留言 :
張貼留言