安卓(Android) 怎么使用分割动画(Animation)启动新活动(Activity)

2019年10月16日22:43:17安卓(Android) 怎么使用分割动画(Animation)启动新活动(Activity)已关闭评论 406 1140字阅读3分48秒

1.简介

安卓(Android) 怎么使用分割动画(Animation)启动新活动(Activity)?——请看下文。

2.示例代码

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



import android.app.Activity;

import android.content.Intent;
import android.graphics.Bitmap;

import android.view.View;

public class Main {
    public static Bitmap mBitmap = null;
    private static int[] mLoc1;
    private static int[] mLoc2;

    
    public static void startActivity(Activity currActivity, Intent intent,
            int splitYCoord) {

        
        prepare(currActivity, splitYCoord);
        currActivity.startActivity(intent);
        currActivity.overridePendingTransition(0, 0);
    }

    
    public static void startActivity(Activity currActivity, Intent intent) {
        startActivity(currActivity, intent, -1);
    }

    private static void prepare(Activity currActivity, int splitYCoord) {

        View root = currActivity.getWindow().getDecorView()
                .findViewById(android.R.id.content);
        root.setDrawingCacheEnabled(true);
        mBitmap = root.getDrawingCache();

        splitYCoord = (splitYCoord != -1 ? splitYCoord : mBitmap
                .getHeight() / 2);

        if (splitYCoord > mBitmap.getHeight())
            throw new IllegalArgumentException("Split Y coordinate ["
                    + splitYCoord + "] exceeds the activity's height ["
                    + mBitmap.getHeight() + "]");

        mLoc1 = new int[] { 0, splitYCoord, root.getTop() };
        mLoc2 = new int[] { splitYCoord, mBitmap.getHeight(), root.getTop() };
    }
}

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