Android:我的片段转换动画有什么问题?

Hao*_* XU 10 animation android transition android-fragments

我只需要简单的幻灯片并滑出动画片段转换,下面是我的代码:slide_in_left.xml:

<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<translate
    android:fromXDelta="-100%"
    android:toXDelta="0%"
    android:fromYDelta="0%"
    android:toYDelta="0%"
    android:duration="700">
</translate>
</set>
Run Code Online (Sandbox Code Playgroud)

slide_out_right.xml:

<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
    android:fromXDelta="0%" android:toXDelta="100%"
    android:fromYDelta="0%" android:toYDelta="0%"
    android:duration="700">
</translate>
</set>
Run Code Online (Sandbox Code Playgroud)

我用的代码:

SomeFragment frag = SomeFragment.newInstance(foo);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
ft.replace(R.id.the_fragment, frag);
ft.addToBackStack(null);

ft.commit();
Run Code Online (Sandbox Code Playgroud)

结果看起来非常奇怪,当转换开始时,当前片段消失而没有动画,输入片段(从左侧)像滚动纸一样.我的动画xml代码出了什么问题?

谢谢!

str*_*rem 5

getSupportFragmentManager()意味着你正在使用Fragments的兼容包,我想.我有同样的问题,根本没有动画发生.

请参阅http://groups.google.com/group/android-developers/browse_thread/thread/5ef5ba1be9f40c56/a846578d91a032c0?hide_quotes=yes#msg_8ca017c473818a04