本文介绍了如何扭转片段动画上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()。
 

解决方案

按照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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 23:45