Android初试--Framlayout(帧布局)

本文介绍了Android中的Framlayout(帧布局),它用于创建空白区域并填充单一对象,子元素固定在左上角,后续元素会覆盖前面的元素。文章通过霓虹灯效果案例,展示了如何在Framlayout中定义多个TextView并实现颜色循环变化。同时,文章还提及了Handler和Timer在更新UI和控制任务执行中的作用。
摘要由CSDN通过智能技术生成

Android初试--Framlayout(帧布局)

        FrameLayout是最简单的一个布局对象。它被定制为你屏幕上的一个空白备用区域,之后你可以在其中填充一个单一对象。比如,一张你要发布的图片。所有的子元素将会固定在屏幕的左上角,你不能为该布局中的一个子元素指定一个位置。后一个子元素将会直接在前一个子元素之上进行覆盖填充,把它们部分或全部挡住(除非后一个子元素是透明的)。

       我们使用网上的霓虹灯效果案例:

参考:http://www.myexception.cn/android/1397052.html

activity_main.xml布局文件:

<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"

 >

 <!-- 依次定义6TextView,先定义的TextView位于底层 -->

    <TextView android:id="@+id/text01"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center"

        android:width="320dp"

        android:height="320dp"

        android:background="#f00"

        />

    <TextView android:id="@+id/text02"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center"

        android:width="280dp"

        android:height="280dp"

        android:background="#0f0"

        />

    <TextView android:id="@+id/text03"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center"

        android:width="240dp"

        android:height="240dp"

        android:background="#00f"

        />

    <TextView android:id="@+id/text04"

        android:layout_width="wrap_content"

        android:layout

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值