Animating fragments and the back stack

╄→гoц情女王★ 提交于 2019-12-02 16:06:06

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).

I use this:

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

and the transitions work in reverse when the back button is presses.

It's a bug, look at bug report 15623. One of the Android project members commented that the fix was too late for release 3.1 but it should make it into the next release.

The same member goes on to say that...

The problem is that the same animations are run on a pop operation as were run to put the fragments in their current places. For example, in the sliding example above, on a forward operation (pushing the old fragment onto the stack and moving the new fragment into view), we slide the old fragment out from the center to the left and slide the new fragment in from the right to the center. When the stack is popped, these same animations are run: the most recent fragment is animated 'out' by sliding it in from the right to the center (after which it disappears, since it's being removed). The old fragment is popped off the stack and animated from teh center to the left ... right off the screen.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!