哪个网站网站空间最好传媒类网站模板
今天学习的这个FrameLayout布局,其实就是分层的意思,有的控件在最上层,有的在最底层。
重要属性:
android:layout_gravity(控件重力)
androidlforeground(前景)
android:foregroundGravity(前景重力)
首先先新建一个布局文件:

命名为:frame_layout

最后就是编写布局文件了,在布局文件中,越靠上写的控件越在最底层,越靠后写的控件,越在最上层:

下面就是代码了:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/fram_l" //界面id名称xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#cccccc"><TextViewandroid:layout_width="400dp"android:layout_height="400dp"android:background="#FF0000"android:layout_gravity="center" //重力居中/><TextViewandroid:layout_width="350dp"android:layout_height="350dp"android:background="#00FF00"android:layout_gravity="center" //重力居中/><TextViewandroid:layout_width="300dp"android:layout_height="300dp"android:background="#0000ff"android:layout_gravity="center" //重力居中/><TextViewandroid:layout_width="250dp"android:layout_height="250dp"android:background="#FF0000"android:layout_gravity="center" //重力居中/><TextViewandroid:layout_width="200dp"android:layout_height="200dp"android:background="#FFff00"android:layout_gravity="center" //重力居中/></FrameLayout>下面就是修改启动界面为刚刚创建的贞布局界面:

最后模拟运行:

