• intent跳转时添加动画效果实例


    转自http://blog.csdn.net/yayun0516/article/details/45555945

    系统默认的intent跳转效果非常生硬,丑陋,影响用户体验,怎么添加跳转动画呢?

    首先新建两个动画文件:

    zoomin.xml: 

    [html] view plaincopy
    1. <?xml version="1.0" encoding="utf-8"?>   
    2. <set xmlns:android="http://schemas.android.com/apk/res/android"   
    3. android:interpolator="@android:anim/decelerate_interpolator">   
    4. <scale android:fromXScale="0.1" android:toXScale="1.0"   
    5. android:fromYScale="0.1" android:toYScale="1.0"   
    6. android:pivotX="50%p" android:pivotY="50%p"   
    7. android:duration="300" />   
    8. <!-- 这里为了看到动画演示效果,把动画持续时间设为3秒 -->   
    9. <alpha   
    10. android:fromAlpha="0.1"   
    11. android:toAlpha="1.0"   
    12. android:duration="300" />   
    13. </set>   


    zoomout.xml

    [html] view plaincopy
    1. <?xml version="1.0" encoding="utf-8"?>   
    2. <set xmlns:android="http://schemas.android.com/apk/res/android"   
    3. android:interpolator="@android:anim/decelerate_interpolator"   
    4. android:zAdjustment="top">   
    5. <scale android:fromXScale="1.0" android:toXScale=".5"   
    6. android:fromYScale="1.0" android:toYScale=".5"   
    7. android:pivotX="50%p" android:pivotY="50%p"   
    8. android:duration="300" />   
    9. <!-- 系统内置的动画持续时间   
    10. android:duration="@android:integer/config_mediumAnimTime"   
    11. -->   
    12. <alpha android:fromAlpha="1.0" android:toAlpha="0"   
    13. android:duration="300"/>   
    14. </set>   


    然后只需在startActivity(intent)后面添加一句:

    overridePendingTransition(R.anim.zoomin, R.anim.zoomout);

    即可实现跳转动画效果,可以试试。


  • 相关阅读:
    滚动数组
    leetcode动态规划
    初中数学学习
    LCS最长公共子序列
    Help Jimmy
    IntelliJ IDEA 设置和查看内存使用
    无法嵌入互操作类型“ApplicationClass”。请改用适用的接口
    代码重构与单元测试——重构6:使用“多态”取代条件表达式(九)
    一个屌丝程序猿的人生(一百二十六)
    一个屌丝程序猿的人生(一百二十五)
  • 原文地址:https://www.cnblogs.com/walccott/p/4957587.html
Copyright © 2020-2023  润新知