zoukankan      html  css  js  c++  java
  • Android 动态渐变按钮

    先上个图




    看着特别炫酷吧

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

              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>

  • 相关阅读:
    MyISAM和InnoDB的区别
    MySQL——索引与优化
    jquery选择器及效率问题
    Mac 可设置环境变量的位置、查看和添加PATH环境变量
    javascript默认中文(汉字/标点)长度均为1的解决
    苹果下抓屏截屏方法 包括全屏、选择区域、窗口抓屏等
    java实现window phone推送通知
    设计模式总结
    NHibernate 帮助类(单例实际运用)
    访问者模式
  • 原文地址:https://www.cnblogs.com/lyfankai/p/10340532.html
Copyright © 2011-2022 走看看