So I've got WelcomeActivity -> HomeActivity and closing WelcomeActivity with finish()/supportFinishAfterTransition()
. I want to do either a slideTransition or a fadeTransition (open to other suggestions btw).
I've researched this and as it turns out there are 2+ ways of doing it: either with overridePendingTransition
which uses anim.xml files or with Transitions (from the android docs) which use transition.xml files...
I've tried both and both give me unwanted results:
- for anims: I get this ugly mid transition black screen:
fade_in.xml:
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="300" />
fade_out.xml:
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:zAdjustment="top"
android:duration="300" />
WelcomeActivity: (I've tried having finish before the overridePendingTransaction)
startActivity(Intent(this, HomeActivity::class.java))
overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
finish()
- for transitions: I can't make it so WelcomeActivity closes properly: It either closes before the animation starts or not closing at all. I'm following the android docs.. I've also tried this:
style.xml
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowEnterTransition">@transition/enter_fade</item>
<item name="android:windowExitTransition">@transition/exit_fade</item>
My other questions is which approach should I have? Is Google pushing the transitions over the anims for starting new activities?