zoukankan      html  css  js  c++  java
  • android overridePendingTransition

    实现两个 Activity 切换时的动画。在Activity中使用
    有两个参数:进入动画和出去的动画。

    注意
    1、必须在 StartActivity()  或 finish() 之后立即调用。
    2、而且在 2.1 以上版本有效
    3、手机设置-显示-动画,要开启状态

    //实现淡入浅出的效果
    startActivity(new Intent(MainActivity.this,SecondActivity.class));
    overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);

    // 由左向右滑入的效果
    startActivity(new Intent(MainActivity.this,SecondActivity.class));
    overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);

    // 实现zoommin 和 zoomout (自定义的动画)
    startActivity(new Intent(OverridePendingTransitionActivity.this,SecondActivity.class));
    overridePendingTransition(R.anim.zoomin, R.anim.zoomout);


    anim/zoomin.xml
    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator" >
      <scale
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromXScale="0.1"
            android:fromYScale="0.1"
            android:pivotX="50%p"
            android:pivotY="50%p"
            android:toXScale="1.0"
            android:toYScale="1.0" />
      <alpha
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromAlpha="0"
            android:toAlpha="1.0" />
    </set>

    anim/zoomout.xml
    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:zAdjustment="top" >
        <scale
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromXScale="1.0"
            android:fromYScale="1.0"
            android:pivotX="50%p"
            android:pivotY="50%p"
            android:toXScale="0.1"
            android:toYScale="0.1" />
        <alpha
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromAlpha="1.0"
            android:toAlpha="0" />
    </set>

  • 相关阅读:
    Tomcat:基于HTTP协议的Connector配置
    Tomcat:云环境下的Tomcat设计思路——Tomcat的多实例安装
    Tomcat:基于Apache+Tomcat的集群搭建
    Java Security:keytool工具使用说明
    Java Security:Java加密框架(JCA)简要说明
    Java Security:公钥私钥、数字签名、消息摘要是什么
    Java Se:Java Security
    Tomcat源码解读:ClassLoader的设计
    Java Se:自定义ClassLoader
    Java Se: Logging 框架说明
  • 原文地址:https://www.cnblogs.com/lechance/p/4373358.html
Copyright © 2011-2022 走看看