Android应用开发之FrameLayout(帧布局)
生活随笔
收集整理的這篇文章主要介紹了
Android应用开发之FrameLayout(帧布局)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
FrameLayout
FrameLayout(幀布局)顧名思義,就是按照幀來(lái)分布的一種布局.
使用示意:
使用FrameLayout,會(huì)直接在屏幕上開辟出一塊空白的區(qū)域.
采用幀布局時(shí),所有控件都默認(rèn)顯示在屏幕左上角,并按照先后放入的順序重疊擺放,先放入的將會(huì)在更底層,后放入的控件顯示在最頂層。幀布局使用于圖層設(shè)計(jì)。
屬性
常用屬性
FrameLayout的屬性有兩個(gè):
| android:foreground | 設(shè)置改幀布局容器的前景圖像 |
| android:foregroundGravity | 設(shè)置前景圖像顯示的位置 |
實(shí)戰(zhàn)代碼
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:foreground="@drawable/ic_launcher_background"android:foregroundGravity="right|bottom"tools:context=".MainActivity"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="400dp"android:background="#000000"></LinearLayout><LinearLayoutandroid:layout_width="300dp"android:layout_height="300dp"android:background="#DB0505"></LinearLayout><LinearLayoutandroid:layout_width="200dp"android:layout_height="200dp"android:background="#A6C012"></LinearLayout></FrameLayout>運(yùn)行效果:
總結(jié)
以上是生活随笔為你收集整理的Android应用开发之FrameLayout(帧布局)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 中国教育在于农村
- 下一篇: 标准件螺钉的种类概括