弹出片段动画

时间:2016-01-26 12:34:12

标签: java android

我正在尝试从后台堆叠弹出的片段,但任何尝试都是失败的。此外,我尝试了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();
    }

0 个答案:

没有答案