我發明了一種動畫的所有視圖在活動
private void doNextPage() {
final ImageView imageView= new ImageView(this);
final FrameLayout frameLayout=(FrameLayout)findViewById(android.R.id.content);
LinearLayout linearLayout=(LinearLayout) frameLayout.findViewById(R.id.rootContainer);
imageView.setImageBitmap(getBitmapFromView(frameLayout));
frameLayout.addView(imageView, 1, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
-------------------- Do Changes -------------------
Animation slideOutRight = AnimationUtils.loadAnimation(this,
R.anim.slide_out_right);
imageView.startAnimation(slideOutRight);
slideOutRight.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
frameLayout.removeView(imageView);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
Animation slideInRight = AnimationUtils.loadAnimation(this,
R.anim.slide_in_right);
linearLayout.startAnimation(slideInRight);
}
public static Bitmap getBitmapFromView(View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable =view.getBackground();
if (bgDrawable!=null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.TRANSPARENT);
view.draw(canvas);
return returnedBitmap;
}