Oreo: disable Activity transition animation - android

I need to disable Activity transition animation for all the screens in my application. Previous solution worked fine for all Android version:
<style name="base_theme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowAnimationStyle">#null</item>
</style>
... but for Android 8 "Oreo" it cause black screen blinking for every transition (forward or back move). I.e. there is still no any animation, but very annoying blinking take place (90% chance, ~20-30 milliseconds, the whole screen).
According to my "research":
it does not depends on activity content and reproduced with empty activities
there is no any background work which could slow down the transition process
Intent.FLAG_ACTIVITY_NO_ANIMATION blinks as well
overridePendingTransition(0,0) doesn't work too
The only solution I could find:
Define an empty transition animation
<?xml version="1.0" encoding="utf-8"?>
<set />
and apply it to every activity in the application (onCreate & finish)
overridePendingTransition(R.anim.animation_activity_none, R.anim.animation_activity_none);
Question:
Is it some kind of new restrictions for Oreo (i.e. feature), or platform bug, or maybe the application issue?
Are there any other solutions?
[UPDATE]
One more finding. Make sure you call Activity finish() and overridePendingTransition() pair on the main thread! Otherwise thread race happens and overridePendingTransition not applied sometimes.
[UPDATE]
Google has confirmed it's a bug in Android 8.0, presumably fixed in 8.1.
So the "empty animation" fix is for years, until minSdkVersion == 27.

I had the same issue, and I managed to solve it, the idea is to play nothing, please see the xml below:
Values folder
<style name="yourTheme">
<item name="android:windowAnimationStyle">#style/ThemeApp.Animation.Activity.Replace</item>
<style name="ThemeApp.Animation.Activity.Replace">
<item name="android:activityOpenEnterAnimation">#anim/replace_anim</item>
<item name="android:activityOpenExitAnimation">#anim/replace_anim</item>
<item name="android:activityCloseEnterAnimation">#anim/replace_anim</item>
<item name="android:activityCloseExitAnimation">#anim/replace_anim</item>
<item name="android:taskOpenEnterAnimation">#anim/replace_anim</item>
<item name="android:taskOpenExitAnimation">#anim/replace_anim</item>
Anim folder: replace_anim.xml
<set/>

Related

Unwanted Blank screen showing on app start up android jetpack compose - android studio chipmunk.-How to remove it?

I just created an empty project and run it on device. On the app start up it shows a default blank screen on start up(app launch) before the first activity. I went through many answers and didn't find an exact answer or the root cause from where it is showing up. Many answers told to add
<item name="android:windowDisablePreview">true</item>
in themes.xml. Even after adding I still see the blank screen appearing.
Also in some other answer they told about new splash screen api, but I didn't feel it much customizable for doing server calls and other operations in splash screens. Also its available in below 12 versions.
What is right solution to handle this unwanted glitches during app startup?
Your help is highly appreciated.
<resources>
<style name="Theme.Owl" parent="#style/Theme.Material.DayNight.NoActionBar">
<item name="android:colorPrimary">#ff00ff</item>
<item name="android:colorAccent">#ff00ff</item>
<item name="android:statusBarColor">#color/immersive_sys_ui</item>
<item name="android:navigationBarColor">#color/nav_bar</item>
<item name="android:windowDisablePreview">true</item>
</style>
<style name="Theme.Material.DayNight.NoActionBar" parent="#android:style/Theme.Material.Light.NoActionBar" />
</resources>

windowLightStatusBar doesn't work on Android 12 with splash transition disabled

I want the background of the system bars to match the theme background in both light and dark mode. As such, I have the following in my values-v27/styles.xml:
<style name="Theme.SystemBarColors" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:statusBarColor">?android:attr/colorBackground</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="android:navigationBarColor">?android:attr/colorBackground</item>
<item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowTranslucentStatus">false</item>
</style>
My app theme then has that as a parent. This seems to work fine on all relevant Android versions by itself.
However, I also want to disable the exit animation on the OS-provided splash screen. (The OS-provided splash hides to reveal an identical-looking splash screen that our app displays on all Android versions while Chrome is launching to show our TWA, so the exit animation makes the hand off look odd and less seamless.) To disable the exit animation, I call this in onCreate on Android 12+:
getSplashScreen().setOnExitAnimationListener(SplashScreenView::remove);
This works to disable the animation, but has the unfortunate side effect on Android 12 and 12L of also causing windowLightStatusBar and windowLightNavigationBar no longer to take effect. statusBarColor and navigationBarColor are still applied, however, leading to an unfortunate white-on-almost-white appearance for the bars. This only happens in situations where the OS-provided splash is actually displayed. E.g., launch from Android Studio → no OS-splash → windowLight*Bar applied versus launch from home screen → OS-splash displayed → windowLight*Bar not applied.
In contrast windowLight*Bar does appear to be applied in both cases on Android 13, so I'm not sure if I'm doing something wrong or if this is just an Android bug that was later fixed. However, even in the latter case, I'd appreciate any help finding a workaround that allows windowLight*Bar to be applied on 12 and 12L while still allowing a seamless handoff between the two identical-looking splash views.

overridePendingTransition doesn't work if android:windowIsTranslucent is set to true on Android 11

I have an Activity which has a translucent background, in the theme I have:
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#color/transparent</item>
When the Activity is closed I use:
finish();
overridePendingTransition(R.anim.scale_fade_in, R.anim.slide_out_right);
This works fine on any Android version up to Android 10. However, on a device running Android 11 the Activity simply closes and no animation is run.
If I set android:windowIsTranslucent to false in the theme the transition works correctly but I obviously lose the translucent background I need.
Has anyone found a solution to this?

Using overridePendingTransition makes the calling activity disappear when new activity "pops" in in Android Kitkat?

How do I stop this from happening? The calling activity disappears when the new acitivity "pops" in using overridePendingTransition. I am using overridePendingTransition so as to animate on older devices. I just need to stop the calling activity from disappearing like what I have done on LOLLIPOP devices
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.setExitTransition(null);
}
Take note this only happens on Android Kitkat 4.4.
I tried getting a Scene for the whole layout activity and then setting the exitAction to null but it didn't work.
How can I do this?
I found out the answer to this problem just now.
It seems like my theme attributes are messing up the animations. To solve this I had to set the following attributes:
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowIsFloating">true</item>
which were originally:
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">false</item>
After that, it worked properly on Kitkat and I tested on the other APIs and it still works as expected. I hope this helps someone else solving this issue

Android activity transition animation inconsistent

In my one activity page, there are many item.
One of items, use startActivity() go to an android system settings activity,
And its activity transition animation is slide_out_left.
The other items use startActivity() go to my own activity.
and activity transition animation is fade_out(defined in my style.xml).
I think that is a reason, but I don't know why?
Why my style.xml changed all activity transition animation except one.
or its there something I didn't notice?
And how can I consistent all activity transition animation in XML file?
(I know overridePendingTransition() can change the animation, but I want to modify in .xml file, not in java code, to stay my java code easy readable in the future.)
Please have a look at this answer and see whether it solves your issue or not: Start Activity with an animation
In short:
<style name="AppTheme">
<item name="android:windowAnimationStyle">#style/MyAnimation</item>
</style>
<style name="MyAnimation" parent="android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">#anim/open_enter</item>
<item name="android:activityOpenExitAnimation">#anim/open_exit</item>
<item name="android:activityCloseEnterAnimation">#anim/close_enter</item>
<item name="android:activityCloseExitAnimation">#anim/close_exit</item>
</style>
If you think this answers your question, please go to that original link that put in the answer and give the original author credit :)

Categories

Resources