I have a fragment which I want to show slide to the left when open and slide to the right when we close it. The show part works fine but when we close it it works if I use hide() but I want to remove the fragment so that it is not shown on configuration change etc but then the same animation working for hide is not working when remove() is called. See the code below.
This code works meaning it shows the panel going to the right animation
Fragment fragment = getFragmentManager().findFragmentByTag(Tags.PANEL_FRAGMENT_TAG.name());
if (fragment != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_right);
transaction.hide(fragment);
transaction.commit();
}
This code doesn't work..Any pointers? How can I remove the fragment and animation still works..
Fragment fragment = getFragmentManager().findFragmentByTag(Tags.PANEL_FRAGMENT_TAG.name());
if (fragment != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_right);
**transaction.remove(fragment);**
transaction.commit();
}