When replacing a fragment, I use the slide animation available for the lollipop version for Android. It works as expected for this particular replacement, but when you press the back button, the current fragment is pushed out first and then the input animation is reversed (slide).
private void replaceContentFrameByFragment(Fragment replaceBy, String replaceByFragmentTag) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Slide slide = new Slide(Gravity.BOTTOM); slide.setDuration(1000); replaceBy.setEnterTransition(slide); } FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, replaceBy, replaceByFragmentTag); fragmentTransaction.addToBackStack(null); fragmentTransaction.commitAllowingStateLoss(); }
So, how to make a fragment pop up only after the slide animation is completed? I noticed that the activity has a finishAfterTransition () method. Is there something similar for frgament?
Ankur source share