我想使用ViewAnimator从一个视图过渡到另一个视图(在我的测试应用程序中,视图是TextViews)。下面列出了我的两个动画。我看到的行为是两个动画都是在我触发动画后立即开始的,而不是运行InAnimation,一旦完成就运行OutAnimation。我所看到的看起来像风车-旋转出来的视图垂直于旋转视图。我想看到旋转出来的视图从其正常水平位置(0度)变为垂直(90度);然后我想查看视图从垂直(-90度)旋转到水平(0度)的情况。
@ anim / rotate_out.xml
<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0" android:toDegrees="90" android:pivotX="50%"
android:pivotY="50%" android:repeatCount="0" android:duration="500"
android:interpolator="@android:anim/linear_interpolator">
</rotate>
@ anim / rotate_in.xml
<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="-90" android:toDegrees="0" android:pivotX="50%"
android:pivotY="50%" android:repeatCount="0" android:duration="500"
android:interpolator="@android:anim/linear_interpolator">
</rotate>
并在主要活动中onCreate ...
va = (ViewAnimator) findViewById(R.id.ViewFlipper01);
va.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_in));
va.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_out));
有任何想法吗?
最佳答案
也许 ? @ anim / rotate_outin.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0" android:toDegrees="90" android:pivotX="50%"
android:pivotY="50%" android:repeatCount="0" android:duration="500"
android:interpolator="@android:anim/linear_interpolator">
</rotate>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0" android:toDegrees="90" android:pivotX="50%"
android:pivotY="50%" android:repeatCount="0" android:duration="500"
android:interpolator="@android:anim/linear_interpolator">
</rotate>
</set>