Disable default animation from Portrait to Landscape

后端 未结 8 1142
庸人自扰
庸人自扰 2020-11-27 03:30

I have an app with several \'normal\' activities which can run on either landscape or portrait. They are designed for and mostly used on portrait.

This app has one s

8条回答
  •  -上瘾入骨i
    2020-11-27 04:14

    I've put that in the mainActivity and it cancelled the rotation animation:

    @Override
        public void setRequestedOrientation(int requestedOrientation) {
            super.setRequestedOrientation(requestedOrientation);
    
            int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
            Window win = getWindow();
            WindowManager.LayoutParams winParams = win.getAttributes();
            winParams.rotationAnimation = rotationAnimation;
            win.setAttributes(winParams);
    
        }
    

    More details here.

提交回复
热议问题