android 背景梯度渐变

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient
        android:angle="270"
        android:centerColor="#00FF00"
        android:centerX="50%"
        android:centerY="50%"
        android:endColor="#ffffff"
        android:startColor="#FF7700"
        android:type="linear" />

</shape>

再你的res/drawable/文件夹下,创建bg_gradient_orange_green_white.xml文件,内容如上

并将该文件设置你使用的控件的background属性即可

这个是三色效果,通过设置角度270,从上到下,由橙变绿再变白

如果只需要两色的话,只需要把带center的属性去掉即可,xy的值是比例,自己测试就好

5376384d8580586fd0f1ff10ae949c88dae.jpg

参考:http://angrytools.com/android/button/

转载于:https://my.oschina.net/f839903061/blog/2957892

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值