Android五大布局之一幀布局(FrameLayout)


一.FrameLayout(幀布局)重點:

FrameLayout(幀布局)可以說是五大布局中最為簡單的一個布局,這個布局會默認把控件放在屏幕上的左上角的區域,后續添加的控件會覆蓋前一個,如果控件的大小一樣大的話,那么同一時刻就只能看到最上面的那個控件

二.FrameLayout(幀布局)常用屬性:

android:foreground:設置改幀布局容器的前景圖像 
android:foregroundGravity:設置前景圖像顯示的位置

三.例子:

1.首先先創建一個FrameLayout的XML文件

代碼如下:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent" >
 5     
 6     <TextView    
 7         android:layout_width="200dp"    
 8         android:layout_height="200dp"    
 9         android:background="#FF0000" />    
10     <TextView    
11         android:layout_width="150dp"    
12         android:layout_height="150dp"    
13         android:background="#00FFFF" />    
14      <TextView    
15         android:layout_width="100dp"    
16         android:layout_height="100dp"    
17         android:background="#FFFF00" />
18 
19 </FrameLayout>

運行結果如下:

 

 

以上就是我對FrameLayout(幀布局)理解


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM