先上个图

看着特别炫酷吧

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

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. Java 项目UML反向工程转化工具

    今天在看一个模拟器的源码,一个包里有多个类,一个类里又有多个属性和方法,如果按顺序看下来,不仅不能对整个模拟器的框架形成一个大致的认识,而且只会越看越混乱,所以,想到有没有什么工具可以将这些个类以及它 ...

  2. kafka之consumer参数auto.offset.reset 0.10+

    https://blog.csdn.net/dingding_ting/article/details/84862776 https://blog.csdn.net/xianpanjia4616/ar ...

  3. Go 新起点

    因项目需求 又得开始啃Go了,虽然比计划早了点,撸起袖子开始干吧~

  4. C# TableLayoutPanel使用方法

    一.利用TableLayoutPanel类展示表格,以10行5列为例 第1步:在前台创建一个panel,使TableLayoutPanel对象填充其内部. 第2步:创建TableLayoutPanel ...

  5. Fillder Script语法

    官方的Fiddler Script使用文档 http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrRes ...

  6. Windows下为 Eclipse 配置 C/C++ 编译环境(转)

    1.Eclipse及CDT的安装 CDT的全称是C/C++ DevelopmentTools,CDT使得Eclipse能够支持C/C++的开发.直接下载 eclipse CDT 集成版 下载地址:ht ...

  7. kubernetes构建时容器的时间与宿主机不一致的解决方法

    kubernetes默认使用docker容器部署的应用,会出现时间与主机不一致的情况 容器时间与主机差8个小时:主机的与容器的/etc/localtime不一致 解决方法:挂载主机的/etc/loca ...

  8. log4j学习总结

    一直使用log4j来记录日志,但是一直以来没有深入研究过log4j,最近研究了下log4j,下面总结一下: log4j配置: 1. 配置根Logger,其语法为: log4j.rootLogger = ...

  9. MD5加密之提取文件的MD5特征码

    public static String encodeFile(String path) { try { MessageDigest digester = MessageDigest.getInsta ...

  10. 前端进击的巨人(六):知否知否,须知this

    常见this的误解 指向函数自身(源于this英文意思的误解) 指向函数的词法作用域(部分情况) this的应用环境 1. 全局环境 无论是否在严格模式下,全局执行环境中(任何函数体外部)this都指 ...