I made three xml files for the transition.
enter_from_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
none.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
exit_to_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="100%"
android:toYDelta="0%" />
</set>
However, It just works fine in Activities
not in Fragments
.
When I click the back button, the backward transition(pop) works fine. But it doesn't work properly when I call the new fragment. It just blinks when the screen changes.
I tried changing the duration to 50 of none.xml
. And I see the new screen comes in from the right side. And also tried with 10000. But it just delays the changing time.
I am using navigation component. And I defined like this:
<action
android:id="@+id/action_initFragment_to_settingFragment"
app:destination="@id/settingFragment"
app:enterAnim="@anim/enter_from_right"
app:exitAnim="@anim/none"
app:popExitAnim="@anim/exit_to_right"
app:popEnterAnim="@anim/none"/>
What's wrong with it? I think this is because of Z index. Is there any way to give Z index attribute?