由网友(上帝是个妞灬)分享简介:我使用谷歌API 8(的Android 2.2),支持包V4。 它不给任何错误或动画。 It doesn't give any error or animation. 交易:FragmentTransaction transaction = manager.beginTransaction();...
我使用谷歌API 8(的Android 2.2),支持包V4。
它不给任何错误或动画。
It doesn't give any error or animation.
交易:
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.content, myFragment);
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
transaction.commit();
动画:
slide_in_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="700"
android:fromXDelta="-100%"
android:toXDelta="0%" >
</translate>
</set>
slide_out_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="700"
android:fromXDelta="0%"
android:toXDelta="100%" >
</translate>
</set>
有谁知道这里发生了什么?
Does anyone know what is happening here?
推荐答案
我解决了这个问题我自己。该经理被堆放在我的交易之前,我设置动画,所以它不叠加动画交易(可悲的,但真正的),并发生甚至当我提交事务setCustom()方法后。
I solved this problem myself. The manager was stacking my transaction before I set the animation, so it stacks the transaction without animations (sad but true), and that occurs even with if I commit the transaction after the setCustom() method.
解决的办法是先设定动画:
The solution is to set the animations first:
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
transaction.replace(R.id.content, myFragment);
transaction.commit();
相关推荐
最新文章