0

I am using jetpack navigation to navigate between two fragments and I also want to have an animation. I added the following animation:

onEnterAnim: slide_in_right.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">

        <translate android:fromXDelta="100%" android:toXDelta="0%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="500"/>
</set>

navigation_graph.xml

<action
    android:id="@+id/action_mainFragment_to_addWorkoutFragment"
    app:destination="@id/addWorkoutFragment"
    app:enterAnim="@anim/slide_in_right"
    app:popEnterAnim="@anim/slide_in_left"
    app:popExitAnim="@anim/slide_out_right"/>

Button listener:

    adauga.setOnClickListener {
        findNavController().navigate(R.id.action_mainFragment_to_addWorkoutFragment)
    }

The problem is that right before the animation starts, I see a preview of the fragment which has to be animated, just a flash. It's like the fragment is inflated but then it reminds that it has to actually animate it and starts the animation..

Another problem that might have the same cause is that every time the app is started, the very fist animation is laggy, but all the other animation will work smoothly

I wish I could add an example of the error, but it happens pretty quickly

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
Alex Pop
  • 31
  • 5

0 Answers0