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>
    

      

    = = = = = = = = = = = = = = = = = = 天道酬勤 = = = = = = 活在当下 = = = = = = = = = = = = = = = = = =
  • 相关阅读:
    c#数据绑定(3)——数据转化为信息
    c#数据绑定(2)——删除DataTable的数据
    C # 数据绑定(1)——将DataTabel的data添加ListView
    如何下载Chrome离线版EXE安装文件和MSI版安装文件
    Windows Installer (MSI) 详解 参数介绍
    7za.exe 命令行用法,参数介绍
    命令行启动Win7系统操作部分功能
    升级WordPress后开启友情链接管理模块
    如何将文件所有者改为TrustedInstaller
    开机自检时出现问题后会出现各种各样的英文短句解说
  • 原文地址:https://www.cnblogs.com/brillian-Jin/p/9673149.html
Copyright © 2011-2022 走看看