动画片段和背面叠

动画片段和背面叠

本文介绍了动画片段和背面叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用或了解如何喀啦有麻烦FragmentTransactions断背栈处理自定义动画。具体而言,我希望它叫出的动画,但它似乎没有。

I am having trouble using or understanding how poppingFragmentTransactions off of the back stack handles the customanimations. Specifically, I expect it to call the "out" animation, butit doesn't seem to.

我有一个简单的方法来处理片段交易(FragmentTransaction),我添加一个片段,并应用自定义过渡,这样它会淡入/淡出。我也在这背面叠层以使用户可以撤消该交易的后退按钮,从根本上导航到状态的片段之前溶液。

I have a simple method to handle a fragment transaction(FragmentTransaction) where I add a fragment and apply a customtransition so that it will fade-in/fade-out. I am also adding this tothe back stack so that the user can undo that transaction with theback button, essentially navigating to the state before the fragmentwas added.

protected void changeFragment() {
    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
    ft.add(R.id.fragment_container, new TestFragment());
    ft.addToBackStack(null);
    ft.commit();
}

一切的伟大工程向前发展,但是,当用户点击后退按钮,过渡动画不逆转。我的预期是该片段得到了取出时,它会使用淡出动画。相反,它似乎弹出(无动画),然后容器似乎淡入。我不知道这是什么正在发生的事情,但片段绝对不会淡出。

Everything works great moving forward, but when the user clicks theback button, the transition animations do not reverse. What I expectedwas that when the fragment got removed, it would use the fade outanimation. Instead it seems to pop out (without animation) and thenthe container seems to fade in. I'm not sure that this is exactly whatis happening, but the fragment is definitely not fading out.

我的应用程序使用兼容性库添加片段支持,但我认为这是适用于蜂窝(Android的11)也是如此。有谁知道,如果我只是在这里做得不对,或者如果我只是期望太高了?理想情况下,我想动画片段类似于Gmail的(对Xoom的)怎么做的问候向前移动点击的消息,然后返回通过使用回按钮。 preferably不必重写后退按钮功能和我自己的片段状态跟不上,因为我可以有几个交易,我想背出来,我重新发明轮子不是一个球迷。

My application uses the compatibility library to add fragment support,but I assume this to be applicable to Honeycomb (android-11) as well.Does anyone know if I am just doing something wrong here or if I amjust expecting too much? Ideally, I would like to animate thefragments similarly to how Gmail (on the Xoom) does in regards tomoving forward by clicking a message and then back by using the backbutton. Preferably not having to override the back buttonfunctionality and keep up with my own fragment state since I couldhave several "transactions" that I would want to back out of and I amnot a fan of re-inventing wheels.

同时要求对Android开发组:http://groups.google.com/group/android-developers/browse_thread/thread/1136a3a70fa0b6e9

Also asked on the Android Developers Group: http://groups.google.com/group/android-developers/browse_thread/thread/1136a3a70fa0b6e9

推荐答案

在修正了3.2版本通过添加以下新​​的API:

The bug was fixed in the 3.2 release with the addition of the following new api:

http://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations(int, INT,INT,INT)

这是应当注意,它尚未后移植到兼容性库(如上文中的错误报告)。

It's to be noted that it has not yet been back-ported to the compatibility library (as mentioned in the bug report).

这篇关于动画片段和背面叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:07