【发布时间】:2011-10-06 16:23:53
【问题描述】:
我想使用 ViewAnimator 从一个视图转换到另一个视图(在我的测试应用程序中,视图是 TextView)。下面列出了我的两个动画。我看到的行为是两个动画在我触发动画器后立即开始,而不是让 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));
有什么想法吗?
【问题讨论】:
标签: android android-layout view android-animation