zoukankan      html  css  js  c++  java
  • Android课程---帧布局 FrameLayout

    帧布局的特点是:

    1.多个组件,层叠显示

    2.所占位置和大小由组件决定

    示例代码:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="320dp"
            android:height="320dp"
            android:layout_gravity="center"
            android:background="#f00"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="280dp"
            android:height="280dp"
            android:layout_gravity="center"
            android:background="#0f0"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="240dp"
            android:height="240dp"
            android:layout_gravity="center"
            android:background="#00f"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="200dp"
            android:height="200dp"
            android:layout_gravity="center"
            android:background="#ff0"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="160dp"
            android:height="160dp"
            android:layout_gravity="center"
            android:background="#0ff"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="120dp"
            android:height="120dp"
            android:layout_gravity="center"
            android:background="#f0f"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="80dp"
            android:height="80dp"
            android:layout_gravity="center"
            android:background="#000"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="40dp"
            android:height="40dp"
            android:layout_gravity="center"
            android:background="#fff"/>
    
    
    
    </FrameLayout>

    由于帧布局是层叠的,所以放了颜色后就能看出来,效果图如下:

  • 相关阅读:
    String类
    Scanner类
    Object类
    接口
    static关键字
    final关键字
    抽象类
    权限修饰符
    方法重写 (Override)
    面向对象思想特征
  • 原文地址:https://www.cnblogs.com/0927wyj/p/5312605.html
Copyright © 2011-2022 走看看