zoukankan      html  css  js  c++  java
  • Android自定义窗口动画

    第一步,设置出现和消失的xml

    1、在res/anim下创建enter_anim.xml,设置窗口出现的动画

    <?xml version="1.0" encoding="utf-8"?>
    <!-- 弹出时动画 -->
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <scale 
            android:interpolator="@android:anim/accelerate_interpolator"
            android:fromXScale="1.0"
            android:toXScale="1.0"
            android:fromYScale="0.0"
            android:toYScale="1.0"
            android:pivotX="0%"
            android:pivotY="100%"
            android:fillAfter="false"
            android:duration="500"/>
    </set>
    <!--
    android:fromXscale="1.0" 表示开始时X轴缩放比例为 1.0 (原图大小 * 1.0 为原图大小)
    android:toXscale="0.0"表示结束时X轴缩放比例为0.0(原图大小 *0.0 为缩小到看不见)
    android:fromYscale="1.0" 表示开始时Y轴缩放比例为 1.0 (原图大小 * 1.0 为原图大小)
    android:toYscale="0.0"表示结束时Y轴缩放比例为0.0(原图大小 *0.0 为缩小的看不到了)
    android:pivotX="50%" X轴缩放的位置为中心点
    android:pivotY="50%" Y轴缩放的位置为中心点
    android:duration="2000" 动画播放时间 这里是2000毫秒也就是2秒

    -->

    2、在res/anim下创建exit_anim.xml,设置窗口消失的动画

    <?xml version="1.0" encoding="utf-8"?>
    <!-- 退出时动画效果 -->
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <scale 
            android:interpolator="@android:anim/accelerate_interpolator"
            android:fromXScale="1.0"
            android:toXScale="1.0"
            android:fromYScale="1.0"
            android:toYScale="0.0"
            android:pivotX="0%"
            android:pivotY="100%"
            android:fillAfter="false"
            android:duration="500"/>
    </set>
    <!--     
    android:fromXscale="1.0" 表示开始时X轴缩放比例为 1.0 (原图大小 * 1.0 为原图大小)
    android:toXscale="0.0"表示结束时X轴缩放比例为0.0(原图大小 *0.0 为缩小到看不见)
    android:fromYscale="1.0" 表示开始时Y轴缩放比例为 1.0 (原图大小 * 1.0 为原图大小)
    android:toYscale="0.0"表示结束时Y轴缩放比例为0.0(原图大小 *0.0 为缩小的看不到了)
    android:pivotX="50%" X轴缩放的位置为中心点 android:pivotY="50%" Y轴缩放的位置为中心点
    android:duration="2000" 动画播放时间 这里是2000毫秒也就是2秒
    -->

    第二步,在res/values下创建动画style

    <?xml version="1.0" encoding="utf-8"?>
    <!-- 设置出现,消失动画 -->
    <resources>
        <style name="WindowAnim" parent="android:Animation" mce_bogus="1">
            <item name="android:windowEnterAnimation">@anim/enter_anim</item>
            <item name="android:windowExitAnimation">@anim/exit_anim</item>
        </style>
    </resources>


    第三步,在代码中设置动态展现

    window.setWindowAnimations(R.style.WindowAnim); //设置窗口弹出动画  


    最后就可以演示你自己的动画效果了。

     

  • 相关阅读:
    WCF 第十三章 可编程站点 为站点创建操作
    WCF 第十三章 可编程站点 所有都与URI相关
    WCF 第十二章 对等网 使用自定义绑定实现消息定向
    WCF 第十三章 可编程站点 使用WebOperationContext
    Using App.Config for user defined runtime parameters
    WCF 第十三章 可编程站点
    WCF 第十三章 可编程站点 使用AJAX和JSON进行网页编程
    WCF 第十二章 总结
    WCF 第十三章 可编程站点 使用WebGet和WebInvoke
    WCF 第十三章 可编程站点 URI和UriTemplates
  • 原文地址:https://www.cnblogs.com/wytings/p/4116212.html
Copyright © 2011-2022 走看看