android - java.lang.RuntimeException : Unknown animation name: objectAnimator

标签 android animation android-support-library

使用时出现此错误

getActivity().getSupportFragmentManager()
                        .beginTransaction()
                        .setCustomAnimations(
                                R.animator.card_flip_right_in, R.animator.card_flip_right_out,
                                R.animator.card_flip_left_in, R.animator.card_flip_left_out)
                        .replace(R.id.content_fragment, new DaysSinceBirthSettingFragment())
                        .addToBackStack(null)
                        .commit();

但是当我把它改成

getActivity().getFragmentManager()
                        .beginTransaction()
                        .setCustomAnimations(
                                R.animator.card_flip_right_in, R.animator.card_flip_right_out,
                                R.animator.card_flip_left_in, R.animator.card_flip_left_out)
                        .replace(R.id.content_fragment, new DaysSinceBirthSettingFragment())
                        .addToBackStack(null)
                        .commit();

完美运行。但我需要支持旧版本,所以我必须使用 getSupportFragmentManager() 来自的 support-v4。

我读到一些文章说 support-v4 不支持 res/animator,所以我也尝试将我的动画 XML 文件移动到 res/anim 文件夹和通过 R.anim.card_flip_right_in

引用它

但还是不行,谁能告诉我该怎么办?

最佳答案

支持 fragment 管理器不支持动画师(仅动画)。异常消息表明您的 xml 资源中的动画格式错误,可能是因为您已将 animator 移动到此错误的 xml(因为它们具有不同的符号)。您需要以正确的方式编写它:http://developer.android.com/guide/topics/graphics/view-animation.html

关于android - java.lang.RuntimeException : Unknown animation name: objectAnimator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19008808/

相关文章:

java - 在布局中切一个洞或动态遮挡部分 View

javascript - D3.JS:如何制作线条动画

javascript - 使用 jQuery 对插入的元素进行动画处理

c# - Windows 8 Metro 中的爆竹类动画

android - 如何通过指定的x和y坐标获取VectorDrawableCompat的像素颜色

android - 如何将数据从一项 Activity 传输到另一项 Activity ?

java - 当我单击recyclerView时如何从Firestore中获取数据?

android - 在 android 中的 ejabberd 服务器上注册一个新用户

android - 在 Android 上支持库依赖

android - 库必须使用相同的版本错误