我正在使用 v4 android 兼容性库来开发一个平板电脑 UI,它使用专门用于 Android 2.2 设备及更高版本的片段。
一切都在正常工作,除了我无法让任何动画工作,甚至是标准动画。
代码:
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ABCFragment abcFragment = new ABCFragment();
ft.replace(R.id.main_frame_layout_fragment_holder,abcFragment);
ft.addToBackStack(null);
ft.commit();
片段没有使用过渡动画,而是冻结了大约一秒钟,然后就消失了,新的片段出现了。
使用:
ft.setCustomAnimations(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
也不行。
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.synergygb.mycustomapp"
android:id="@+id/LinearLayout01" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
android:gravity="bottom">
<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/main_frame_layout_fragment_holder">
</FrameLayout>
<!-- OTHER FIXED UI ELEMENTS-->
</RelativeLayout>
我读到自定义动画在兼容性库中被破坏,但似乎没有人对标准转换有问题。我已经在 3.2.1 摩托罗拉 Xoom、2.3 Galaxy Tab 7"、2.2 模拟器,甚至是 2.3.4 的 HTC G2 上进行了测试。
这里有什么问题?