1、显示
FragmentManager manager = getSupportFragmentManager();
Fragment fragment = manager.findFragmentByTag(Fragment.TAG);
if (fragment != null) return;
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_right_in, 0);
Fragment fragment = new Fragment();
transaction.add(R.id.frameContainer, fragment,Fragment.TAG);
transaction.commitAllowingStateLoss();
2、隐藏
FragmentManager manager = getSupportFragmentManager();
Fragment fragment =manager.findFragmentByTag(Fragment.TAG);
if (fragment != null) {
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(0, R.anim.slide_right_out);
transaction.remove(fragment);
transaction.commitAllowingStateLoss();
}