安卓(Android) 怎么应用特定动画(Animation)以转换到新屏幕(screen)

2019年10月16日22:51:44安卓(Android) 怎么应用特定动画(Animation)以转换到新屏幕(screen)已关闭评论 292 1603字阅读5分20秒

1.简介

安卓(Android) 怎么应用特定动画(Animation)以转换到新屏幕(screen)?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;

public class Main{
    
     
    public static void ApplyOpenScreenAnimation(Activity activity,
            String animType) {
        if (animType == null) {
            return;
        }
        if (SdkLevel.getLevel() <= SdkLevel.LEVEL_DONUT) {
            Log.e("AnimationUtil",
                    "Screen animations are not available on android versions less than 2.0.");
            return;
        }
        int enter = 0;
        int exit = 0;

        if (animType.equalsIgnoreCase("fade")) {
            enter = activity.getResources().getIdentifier("fadein", "anim",
                    activity.getPackageName());
            exit = activity.getResources().getIdentifier("hold", "anim",
                    activity.getPackageName());
        } else if (animType.equalsIgnoreCase("zoom")) {
            exit = activity.getResources().getIdentifier("zoom_exit",
                    "anim", activity.getPackageName());
            enter = activity.getResources().getIdentifier("zoom_enter",
                    "anim", activity.getPackageName());
        } else if (animType.equalsIgnoreCase("slidehorizontal")) {
            exit = activity.getResources().getIdentifier("slide_exit",
                    "anim", activity.getPackageName());
            enter = activity.getResources().getIdentifier("slide_enter",
                    "anim", activity.getPackageName());
        } else if (animType.equalsIgnoreCase("slidevertical")) {
            exit = activity.getResources().getIdentifier("slide_v_exit",
                    "anim", activity.getPackageName());
            enter = activity.getResources().getIdentifier("slide_v_enter",
                    "anim", activity.getPackageName());
        } else if (animType.equalsIgnoreCase("none")) {
            
            
        } else {
            
            
            return;
        }
        EclairUtil.overridePendingTransitions(activity, enter, exit);
    }
}

 
继续阅读
编程十万个怎么办