I am trying to figure out what is the proper way to play transition animation when popBacksStack is called.
Right now I am setting the transition from ListFragment to SettingsFragment like this
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(null)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.replace(R.id.fragment_holder, settingsFragment)
.commit();
But how should I play the transition when popping backstack (Moving back so that ListFragment becomes visible again)?
As I noticed, popping backstack is not a fragmentManager transaction like replacing a fragment so I cannot call the setTransition before making the pop.
I would like to keep the code as simple as possible. No custom animations etc.
Solution: I ques I have got too used to Android Studio being smarted than me. Android studio didn't recognize android.R as resource so I thought there is not such thing, but when I started to type in the full path 'android.R.anim.slide_in_left' Android studio picked it up. So my solution looks like this now:
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(null)
.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right, android.R.anim.slide_in_left, android.R.anim.slide_out_right)
.replace(R.id.fragment_holder, settingsFragment)
.commit();