我正在尝试从后台堆叠弹出的片段,但任何尝试都是失败的。此外,我尝试了SetCustomAnimation(int i1,int i2,int i3,int i4),但我做了什么,它没有动画,只是出现。
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}
else if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction().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);
for(Fragment s:getSupportFragmentManager().getFragments()){
if(s!=null&&!s.isDetached()){
ft.remove(s);
}
}
getSupportFragmentManager().popBackStackImmediate();
ft.commit();
return;
}
super.onBackPressed();
}