Android: change activity transition to crossfade not working in specific situation

340 views Asked by At

I have two activities, let's call them Main and Second. The Main one's orientation is limited to landscape and reversed landscape (via android:screenOrientation="sensorLandscape" in manifest) and the Second one is always landscape (android:screenOrientation="landscape"). I would like to keep crossfade transition between them all the time. I'm using this code to make it happen:

int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_CROSSFADE;
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
winParams.rotationAnimation = rotationAnimation;
win.setAttributes(winParams);

It's called in onCreate() and onResume() in both activities. This mechanism works nice when switching from Main to Second (both landscape and reversed landscape) and when going back from Second to Main in landscape. Problem occurs when I'm in reversed landscape in Second activity and I try to go back to Main. In this case standard rotation animation triggers (Second is in locked to landscape, and Main adapts to reversed landscape). So somehow my crossfade animation is ignored.
Interestingly enough, on Android 5 (Samsing Galaxy S6) crossfade animation is always properly used, and this issue does not occur. The the other devices are using Android 4.4.2 and 4.4.4.
I tried to work this around using overridePendingTransition(int enterAnim, int exitAnim) but it didn't change things a bit.

How can I fix or workaround this problem?

0

There are 0 answers