如何扭转片段动画上BackStack? [英] How to Reverse Fragment Animations on BackStack?

查看:101
本文介绍了如何扭转片段动画上BackStack?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还以为系统会扭转时后退按钮是用下面的code。使用片段时,pssed $ P $的backstack动画:

  FragmentManager FM = getFragmentManager();
FragmentTransaction英尺= fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in,R.anim.hyperspace_out);
ft.replace(R.id.viewContainer,新类(),布局)addToBackStack(空).commit()。
 

解决方案

按照<一个href="http://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations(int,%20int,%20int,%20int)">android自定义动画文档:

修改

  ft.setCustomAnimations(R.anim.slide_in,R.anim.hyperspace_out);
 

要:

  ft.setCustomAnimations(R.anim.slide_in,R.anim.hyperspace_out,R.anim.hyperspace_in,R.anim.slide_out);
 

现在的backstack动画 - 在逆向!!

I thought the system would reverse animations on the backstack when the back button is pressed when using fragments using the following code:

FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out);
ft.replace(R.id.viewContainer, new class(), "layout").addToBackStack(null).commit();

解决方案

According to the android documentation for custom animation:

Change:

ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out);

To:

ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out, R.anim.hyperspace_in, R.anim.slide_out );

and now the backstack animates - In reverse!!

这篇关于如何扭转片段动画上BackStack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆