帧布局

来源:互联网 发布:数据分析之淘宝大卖家 编辑:程序博客网 时间:2024/06/07 22:30

帧布局由FrameLayout所代表,直接继承了ViewGroup组件。

下面是使用帧布局的页面定义代码:

<?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:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    app:layout_behavior="@string/appbar_scrolling_view_behavior"    tools:context="com.example.l2112.zhenbuju.MainActivity"    tools:showIn="@layout/activity_main">    <!-- 依次定义6个TextView,先定义的TextView位于底层 -->    <TextView        android:id="@+id/view01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:width="140pt"        android:height="140pt"        android:background="#f00"/>    <TextView        android:id="@+id/view02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:width="120pt"        android:height="120pt"        android:background="#0f0"/>    <TextView        android:id="@+id/view03"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:width="100pt"        android:height="100pt"        android:background="#00f"/>    <TextView        android:id="@+id/view04"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:width="80pt"        android:height="80pt"        android:background="#ff0"/>    <TextView        android:id="@+id/view05"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:width="60pt"        android:height="60pt"        android:background="#f0f"/>    <TextView        android:id="@+id/view06"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:width="40pt"        android:height="40pt"        android:background="#0ff"/></FrameLayout>


0 0
原创粉丝点击