I would like to make slide transition in both ways between two fragments. What i have done is working now in enter animation and popExit, not popEnter(previous fragment shows without transition).
My transition action looks like this:
<action
android:id="@+id/action_welcomeFragment_to_interfaceScalePickFragment"
app:destination="@id/interfaceScalePickFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
One of my custom animations looks like that(it's slide_out_left)
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="0%" android:toXDelta="-100%"/>
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="0.0" />
</set>
And my, for example, welcome fragment is written like this:
package com.delet_dis.elementarylauncher.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.findNavController
import com.delet_dis.elementarylauncher.R
import com.delet_dis.elementarylauncher.databinding.FragmentWelcomeScreenBinding
class WelcomeFragment : Fragment() {
private lateinit var binding: FragmentWelcomeScreenBinding
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return if (savedInstanceState == null) {
binding = FragmentWelcomeScreenBinding.inflate(layoutInflater)
binding.root
} else {
view
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (savedInstanceState == null) {
binding.getStartedButton.setOnClickListener {
requireActivity().findNavController(R.id.fragmentContainerView)
.navigate(R.id.action_welcomeFragment_to_interfaceScalePickFragment)
}
}
}
}
I tried to rewrite project in Canary version(because recently the host was not displayed in the release version, but everything worked in canary).
I also tried to replace first fragment(welcome) with studio-built fragment, the error in the absence of animation is repeated