zoukankan      html  css  js  c++  java
  • view 状态动画

    stateListAnimator

    一、xml配置 方法

    res/xml/animate_scale.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- the pressed state; increase x and y size to 150% -->
        <item android:state_pressed="true">
            <set>
                <objectAnimator android:propertyName="scaleX"
                    android:duration="@android:integer/config_shortAnimTime"
                    android:valueTo="1.5"
                    android:valueType="floatType"/>
                <objectAnimator android:propertyName="scaleY"
                    android:duration="@android:integer/config_shortAnimTime"
                    android:valueTo="1.5"
                    android:valueType="floatType"/>
            </set>
        </item>
        <!-- the default, non-pressed state; set x and y size to 100% -->
        <item android:state_pressed="false">
            <set>
                <objectAnimator android:propertyName="scaleX"
                    android:duration="@android:integer/config_shortAnimTime"
                    android:valueTo="1"
                    android:valueType="floatType"/>
                <objectAnimator android:propertyName="scaleY"
                    android:duration="@android:integer/config_shortAnimTime"
                    android:valueTo="1"
                    android:valueType="floatType"/>
            </set>
        </item>
    </selector>
    

      调用方:

    <Button android:stateListAnimator="@xml/animate_scale"
            ... />
    

    二、java代码中调用

    AnimatorInflater.loadStateListAnimator()
    View.setStateListAnimator() 
    

    AnimatedStateListDrawable

    <!-- res/drawable/myanimstatedrawable.xml -->
    <animated-selector
        xmlns:android="http://schemas.android.com/apk/res/android">
    
        <!-- provide a different drawable for each state-->
        <item android:id="@+id/pressed" android:drawable="@drawable/drawableP"
            android:state_pressed="true"/>
        <item android:id="@+id/focused" android:drawable="@drawable/drawableF"
            android:state_focused="true"/>
        <item android:id="@id/default"
            android:drawable="@drawable/drawableD"/>
    
        <!-- specify a transition -->
        <transition android:fromId="@+id/default" android:toId="@+id/pressed">
            <animation-list>
                <item android:duration="15" android:drawable="@drawable/dt1"/>
                <item android:duration="15" android:drawable="@drawable/dt2"/>
                ...
            </animation-list>
        </transition>
        ...
    </animated-selector>
    

      

    = = = = = = = = = = = = = = = = = = 天道酬勤 = = = = = = 活在当下 = = = = = = = = = = = = = = = = = =
  • 相关阅读:
    将博客搬至CSDN
    js进制转换
    js千分位转换
    css让div水平垂直居中
    NPM与调试工具的使用
    Windows下Node.js开发环境搭建-合适的开发环境
    Node.js开发环境介绍-调试工具
    开发环境
    模拟实现call,apply,bind方法,以及三者区别
    观察者模式
  • 原文地址:https://www.cnblogs.com/brillian-Jin/p/9673149.html
Copyright © 2011-2022 走看看