我一直试图在从一个片段滑动到另一个片段的同时制作3D立方体旋转效果.首先我使用的是翻译效果(在XML上)调用,FragmentTransaction.setCustomAnimations(...)然后,当打开/关闭片段时,我正在使用Camera classe进行旋转.
这工作很精细,但似乎我有太多(不要问我为什么)只使用XML文件使用所有这个动画.经过长时间的搜索,我发现我应该使用objectAnimator进行旋转.
跟着谷歌样本,我设法制作翻转动画.现在我需要翻译片段,让它们滑入并滑出.似乎我不能使用objectAnimator并在同一XML文件上转换效果.由于出现此错误:
java.lang.RuntimeException: Unknown animator name: translate at (...)
Run Code Online (Sandbox Code Playgroud)
关于如何制作滑动效果并同时使用objectAnimator的任何想法?
感谢您的时间!
代码我一直在使用:
card_flip_right_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Before rotating, immediately set the alpha to 0. -->
<objectAnimator
android:duration="0"
android:propertyName="alpha"
android:valueFrom="1.0"
android:valueTo="0.0" />
<!-- Rotate. -->
<objectAnimator
android:duration="@integer/card_flip_time_full"
android:interpolator="@android:interpolator/accelerate_decelerate"
android:propertyName="rotationY"
android:valueFrom="180"
android:valueTo="0" />
<!-- Half-way through the rotation (see startOffset), set the alpha to 1. -->
<objectAnimator
android:duration="1"
android:propertyName="alpha"
android:startOffset="@integer/card_flip_time_half"
android:valueFrom="0.0"
android:valueTo="1.0" />
</set>
Run Code Online (Sandbox Code Playgroud)
片段调用另一个片段:(在此2之间应该可以看到立方体旋转)
private void launchArticle(int prev, int pos){
ArticleFragment newFragment = new ArticleFragment();
Bundle …Run Code Online (Sandbox Code Playgroud)