先上个图

看着特别炫酷吧

其实就是自定义颜色两秒轮播
动画

AnimationDrawable animationDrawable = (AnimationDrawable) button.getBackground();
    //      animationDrawable.setEnterFadeDuration(2000);
            animationDrawable.setExitFadeDuration(2000);
            animationDrawable.start();

xml

long_button_gradient

<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
     
        <item
            android:drawable="@drawable/long_color_gradient1"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient2"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient3"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient4"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient5"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient6"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient7"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient8"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient9"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient10"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient11"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient12"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient13"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient14"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient15"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient16"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient17"
            android:duration="2000" />
     
        <item
            android:drawable="@drawable/long_color_gradient18"
            android:duration="2000" />
    </animation-list>

long_color_gradient1-long_color_gradientN(渐变一到渐变N)

<shape xmlns:android="http://schemas.android.com/apk/res/android">
     
        <corners android:radius="@dimen/button_gradient_fillet" />
     
        <gradient
            android:angle="45"
            android:centerColor="@color/color_gradient_2"
            android:endColor="@color/color_gradient_3"
            android:startColor="@color/color_gradient_1"
            android:type="linear" />
    </shape>

color

<!--++++++++++++++渐变button+++++++++++++++++-->
        <color name="color_gradient_1">#ffdc6b</color>
        <color name="color_gradient_2">#ffe96b</color>
        <color name="color_gradient_3">#daff6b</color>
        <color name="color_gradient_4">#9fff6b</color>
        <color name="color_gradient_5">#6aff84</color>
        <color name="color_gradient_6">#69ff79</color>
        <color name="color_gradient_7">#6affb5</color>
        <color name="color_gradient_8">#6bffee</color>
        <color name="color_gradient_9">#69cdff</color>
        <color name="color_gradient_X">#6ac6ff</color>
     
        <color name="color_7FC13F">#7FC13F</color>
        <color name="color_E9E9E9">#e9e9e9</color>
        <color name="color_777777">#777777</color>

dimens
    <dimen name="button_gradient_fillet">7dp</dimen>

Android 动态渐变按钮的更多相关文章

  1. Android动态换肤(二、apk免安装插件方式)

    在上一篇文章Android动态换肤(一.应用内置多套皮肤)中,我们了解到,动态换肤无非就是调用view的setBackgroundResource(R.drawable.id)等方法设置控件的背景或者 ...

  2. android 动态壁纸开发

    转:http://www.eoeandroid.com/thread-100389-1-1.html android 动态壁纸开发参考:http://www.ophonesdn.com/article ...

  3. [转载] Android动态加载Dex机制解析

    本文转载自: http://blog.csdn.net/wy353208214/article/details/50859422 1.什么是类加载器? 类加载器(class loader)是 Java ...

  4. Android 动态加载 (二) 态加载机制 案例二

    探秘腾讯Android手机游戏平台之不安装游戏APK直接启动法 重要说明 在实践的过程中大家都会发现资源引用的问题,这里重点声明两点: 1. 资源文件是不能直接inflate的,如果简单的话直接在程序 ...

  5. Android 动态加载 (一) 态加载机制 案例一

    在目前的软硬件环境下,Native App与Web App在用户体验上有着明显的优势,但在实际项目中有些会因为业务的频繁变更而频繁的升级客户端,造成较差的用户体验,而这也恰恰是Web App的优势.本 ...

  6. 深入浅出Android动态载入jar包技术

    在实际项目中.因为某些业务频繁变更而导致频繁升级client的弊病会造成较差的用户体验,而这也恰是Web App的优势,于是便衍生了一种思路.将核心的易于变更的业务封装在jar包里然后通过网络下载下来 ...

  7. Android动态加载技术初探

    一.前言: 现在,已经有实力强大的公司用这个技术开发应用了,比如淘宝,大众点评,百度地图等,之所以采用这个技术,实际上,就是方便更新功能,当然,前提是新旧功能的接口一致,不然会报Not Found等错 ...

  8. MFC动态创建按钮,并在按钮上实现位图的切换显示

    动态创建按钮,并在按钮中添加位图,通过单击按钮显示不同的位图,可设置为显示按钮按下和弹起两种状态.只要判断a值从而输入不同的响应代码. 1.在头文件中添加: CButton *pBtn; 2.在初始化 ...

  9. Android应用开发提高系列(4)——Android动态加载(上)——加载未安装APK中的类

    前言 近期做换肤功能,由于换肤程度较高,受限于平台本身,实现起来较复杂,暂时搁置了该功能,但也积累了一些经验,将分两篇文章来写这部分的内容,欢迎交流! 关键字:Android动态加载 声明 欢迎转载, ...

随机推荐

  1. log4j 详细使用教程【转载】

    日志是应用软件中不可缺少的部分,Apache的开源项目log4j是一个功能强大的日志组件,提供方便的日志记录.在apache网站:jakarta.apache.org/log4j 可以免费下载到Log ...

  2. Spring MVC 后端获取前端提交的json格式字符串并直接转换成control方法对应的参数对象

    场景: 在web应用开发中,spring mvc凭借出现的性能和良好的可扩展性,导致使用日渐增多,成为事实标准,在日常的开发过程中,有一个很常见的场景:即前端通过ajax提交方式,提交参数为一个jso ...

  3. Webpack代理proxy配置,解决本地跨域调试问题,同时允许绑定host域名调试

    Webpack代理proxy配置,解决本地跨域调试问题,同时允许绑定host域名调试 会撸码的小马 关注 2018.05.29 17:30* 字数 212 阅读 1488评论 0喜欢 2 接到上一章, ...

  4. 学习DDD之路--勇于纠正自己的错误

    写这篇文章主要是之前三篇对DDD的介绍算是自己学习的一次试水,也希望能够有更多的人能帮我发现其中的问题.昨天继续阅读了DDD书,发现了自己之前的例子存在了一些问题,早上也和园友进行了一些讨论.最后整理 ...

  5. django--form相关

    简单用法: Django提供 Form组件:            1. 定义规则                from django.forms import Form               ...

  6. 安装和配置jBPM4,并举个hello.w

    至于网上很复杂,但又不懂的插件,我们先不鸟他. myeclipse8\dropins这里就是给我们放插件的,类似SVN之类的.所以小生也修改了下,共享了下.只有放在目录下,打开应该可以的.下面是链接. ...

  7. Shell脚本 | 性能测试之内存

    性能测试中,内存是一个不可或缺的方面.比如说在跑 Monkey 的过程中,如何准确持续的获取到内存数据就显得尤为重要. 今天分享一个脚本,可以在给定时间内持续监控内存,最后输出成一份 CSV 文件,通 ...

  8. 解决Android Studio 3.x版本的安装时没有SDK,运行时出现SDK tools错误

    好久没更新了,最近手机上的闹钟APP没一个好用的,所以想自己写个. 那Android开发环境搭起来,注意先装好jdk. 1.安装Android Studio google的Android开发网站已经有 ...

  9. Kafka的Log存储解析

    引言 Kafka中的Message是以topic为基本单位组织的,不同的topic之间是相互独立的.每个topic又可以分成几个不同的partition(每个topic有几个partition是在创建 ...

  10. Deep learning with Python 学习笔记(8)

    Keras 函数式编程 利用 Keras 函数式 API,你可以构建类图(graph-like)模型.在不同的输入之间共享某一层,并且还可以像使用 Python 函数一样使用 Keras 模型.Ker ...