Android应用开发之FrameLayout(帧布局)
生活随笔
收集整理的這篇文章主要介紹了
Android应用开发之FrameLayout(帧布局)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
FrameLayout
FrameLayout(幀布局)顧名思義,就是按照幀來分布的一種布局.
使用示意:
使用FrameLayout,會直接在屏幕上開辟出一塊空白的區域.
采用幀布局時,所有控件都默認顯示在屏幕左上角,并按照先后放入的順序重疊擺放,先放入的將會在更底層,后放入的控件顯示在最頂層。幀布局使用于圖層設計。
屬性
常用屬性
FrameLayout的屬性有兩個:
| android:foreground | 設置改幀布局容器的前景圖像 |
| android:foregroundGravity | 設置前景圖像顯示的位置 |
實戰代碼
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>運行效果:
總結
以上是生活随笔為你收集整理的Android应用开发之FrameLayout(帧布局)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国教育在于农村
- 下一篇: android中蓝牙的使用方法,Andr