zoukankan      html  css  js  c++  java
  • 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);

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


  • 相关阅读:
    生成器 三元表达式 列表生成式 匿名函数 内置函数
    迭代器
    叠加装饰器和补充部分
    函数的名称空间和作用域
    函数基础
    闭包函数和装饰器
    文件的处理
    第十章 程序的循环结构
    第九章 身体质量指数BMI的python实现
    第八章 程序的分支结构
  • 原文地址:https://www.cnblogs.com/walccott/p/4957587.html
Copyright © 2011-2022 走看看