使用时出现此错误
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/