Android布局之FrameLayout幀布局
前言
作為android六大布局中最為簡(jiǎn)單的布局之一,該布局直接在屏幕上開辟出了一塊空白區(qū)域,
當(dāng)我們往里面添加組件的時(shí)候,所有的組件都會(huì)放置于這塊區(qū)域的左上角;
幀布局的大小由子控件中最大的子控件決定,如果都組件都一樣大的話,同一時(shí)刻就只能能看到最上面的那個(gè)組件了!
當(dāng)然我們也可以為組件添加layout_gravity屬性,從而制定組件的對(duì)其方式
幀布局在游戲開發(fā)方面用的比較多,等下后面會(huì)給大家演示一下比較有意思的兩個(gè)實(shí)例

(-)幀布局簡(jiǎn)介
幀布局容器為每個(gè)加入的其中的組件創(chuàng)建一個(gè)空白的區(qū)域稱為一幀每個(gè)子組件占據(jù)一幀,這些幀都會(huì)根據(jù)gravity的屬性執(zhí)行自動(dòng)對(duì)齊
(二)常用屬性:
android:foreground:設(shè)置該幀布局容器的前景圖像
android:foregroundGravity:設(shè)置前景圖像顯示的位置
(三)使用
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="300dp" android:height="300dp" android:background="#f00"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="200dp" android:height="200dp" android:background="#0f0"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:width="100dp" android:height="100dp" android:background="#00f"/> </FrameLayout> </LinearLayout>
以上內(nèi)容給大家介紹了Android布局之FrameLayout幀布局,希望大家喜歡。
相關(guān)文章
Android ListView實(shí)現(xiàn)圖文列表顯示
這篇文章主要為大家詳細(xì)介紹了Android ListView實(shí)現(xiàn)圖文列表顯示,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01
Android Studio 3.3.2 正式版的安裝教程圖解
這篇文章主要介紹了Android Studio 3.3.2 正式版的安裝教程圖解,本文分步驟通過圖文并茂的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2020-02-02
Android提高之自定義Menu(TabMenu)實(shí)現(xiàn)方法
這篇文章主要介紹了Android自定義Menu(TabMenu)實(shí)現(xiàn)方法,是非常實(shí)用的功能,需要的朋友可以參考下2014-08-08
Android實(shí)現(xiàn)微信自動(dòng)向附近的人打招呼(AccessibilityService)
這篇文章主要為大家詳細(xì)介紹了實(shí)現(xiàn)微信自動(dòng)向附近的人打招呼,實(shí)現(xiàn)收到指定賬戶推送文章時(shí)自動(dòng)進(jìn)入微信打開鏈接,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12
Flutter StaggeredGridView實(shí)現(xiàn)瀑布流效果
這篇文章主要為大家詳細(xì)介紹了Flutter StaggeredGridView實(shí)現(xiàn)瀑布流效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
Android實(shí)現(xiàn)計(jì)步進(jìn)度的環(huán)形Progress
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)計(jì)步進(jìn)度的環(huán)形Progress,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
Android如何調(diào)用系統(tǒng)相機(jī)拍照
這篇文章主要為大家詳細(xì)介紹了Android如何調(diào)用系統(tǒng)相機(jī)拍照的相關(guān)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09
Android實(shí)現(xiàn)多線程下載圖片的方法
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)多線程下載圖片的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09

