【发布时间】:2011-10-10 20:12:18
【问题描述】:
我正在使用 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 模拟器,甚至在 HTC G2 和 2.3.4 上进行了测试。
这里有什么问题?
【问题讨论】:
-
dalvik(调试器)给你什么了吗?
-
您有任何 logcat 输出要给我们吗?
-
没什么,这就是我迷路的原因。没有错误。 Logcat 什么也没显示。只是系统的定期回调,与正在进行的应用内更改无关。检查它给出的 mTransition 的值 = 4099。该值由以下方式设置:ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
-
我在另一台计算机上设置了整个开发环境,结果相同。
-
刚刚更新了兼容包,结果一样。我在 2.2 Google API 上构建。
标签: android animation android-fragments android-support-library