Android帧布局-实现渐变效果

本文介绍了如何在Android应用中使用XML布局文件来创建7个具有相同高度但宽度逐渐减少的TextView,并设置了背景色渐变效果,确保最先添加的TextView不完全遮挡。
Android帧布局-实现渐变效果
main.xml

    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
   
        android:id="@+id/view01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="210px"
        android:height="50px"
        android:background="#ff0000"/>
   
        android:id="@+id/view02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="180px"
        android:height="50px"
        android:background="#dd0000"/>
   
        android:id="@+id/view03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="150px"
        android:height="50px"
        android:background="#bb0000"/>
   
        android:id="@+id/view04"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="120px"
        android:height="50px"
        android:background="#990000"/>
   
        android:id="@+id/view05"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="90px"
        android:height="50px"
        android:background="#770000"/>
   
        android:id="@+id/view06"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="60px"
        android:height="50px"
        android:background="#550000"/>
   
        android:id="@+id/view07"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="30px"
        android:height="50px"
        android:background="#330000"/>

这7个TextView的高度完全相同,而宽度逐渐减少-这样可以保证最先添加的TextView不完全遮挡,而且我们设置了7个TextView背景色渐变。


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值