帧布局FrameLayout
帧布局FrameLayout是相对简单的布局,这个布局直接在在屏幕上分配一块区域,新创建的组件会默认放在左上角,但可以通过Layout_gravity属性指定到其他位置,这种布局没有任何定位,布局的大小由内部的最大控件决定,如果控件的大小一样大的话,那么同一时刻就只能看到最上面的那个组件!后续添加的控件会覆盖前一个!,应用场景很少。
1.基本语法
<FrameLayout xmlns:android
="http://schemas.android.com/apk/res/android"
属性列表
</FrameLayout
>
FrameLayout 支持的常用XML属性
foreground----设置布局管理器的前景色foregroundGravity----设置前景图像的gravity属性,即前景图像的显示位置
<FrameLayout 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"
tools:context
="${relativePackage}.${activityClass}"
>
<TextView
android:layout_width
="200dp"
android:layout_height
="200dp"
android:background
="#FF0000"
android:text
="first文本"
android:layout_gravity
="center"
/
>
<TextView
android:layout_width
="150dp"
android:layout_height
="150dp"
android:background
="#0000FF"
android:text
="second文本"
android:layout_gravity
="center"
/
>
<TextView
android:layout_width
="100dp"
android:layout_height
="100dp"
android:background
="#00FF00"
android:text
="three文本"
android:layout_gravity
="center"
/
>
</FrameLayout
>
效果:::