Android examples for Animation:Animation Creation
Start a new Activity with a Split animation
//package com.java2s; 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; /**// w w w . ja v a 2 s. c o m * Start a new Activity with a Split animation * * @param currActivity The current Activity * @param intent The Intent needed tot start the new Activity * @param splitYCoord The Y coordinate where we want to split the Activity on the animation. -1 will split the Activity equally */ public static void startActivity(Activity currActivity, Intent intent, int splitYCoord) { // Preparing the bitmaps that we need to show prepare(currActivity, splitYCoord); currActivity.startActivity(intent); currActivity.overridePendingTransition(0, 0); } /** * Start a new Activity with a Split animation right in the middle of the Activity * * @param currActivity The current Activity * @param intent The Intent needed tot start the new Activity */ 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() }; } }