1. 程式人生 > >Android 去掉橫豎屏切換時的動畫

Android 去掉橫豎屏切換時的動畫

直接上程式碼

ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) decorView.getLayoutParams();
//旋轉
//    layoutParams.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE;
//淡入淡出
//    layoutParams.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_CROSSFADE;
//無動畫
//    layoutParams.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
//無縫旋轉模式
layoutParams.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
windowManager.updateViewLayout(decorView, layoutParams);