我想实现一些RotatingImageView和我有一个动画看起来像这样:ViewSwitcher和自定义动画的ImageView
public void init() {
mCurrentRotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.51f);
mCurrentRotateAnimation.setDuration(0);
mCurrentRotateAnimation.setRepeatCount(Animation.INFINITE);
mCurrentRotateAnimation.setRepeatMode(Animation.RESTART);
mCurrentRotateAnimation.setInterpolator(new InfoInterpolator());
startAnimation(mCurrentRotateAnimation);
}
的困难出现时,这RotatingImageView开始在ViewSwitcher使用(这是一ViewAnimator)和ViewSwitcher改变自己依赖于输入/输出动画有动画(基本上是通过调用startAnimation()带着自己的进/出动画,将覆盖我的旋转动画:
// ViewSwitcher/ViewAnimator code changing the animation
void showOnly(int childIndex, boolean animate) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (i == childIndex) {
if (animate && mInAnimation != null) {
child.startAnimation(mInAnimation);
}
child.setVisibility(View.VISIBLE);
mFirstTime = false;
} else {
if (animate && mOutAnimation != null && child.getVisibility() == View.VISIBLE) {
child.startAnimation(mOutAnimation);
} else if (child.getAnimation() == mInAnimation)
child.clearAnimation();
child.setVisibility(View.GONE);
}
}
}
我试图通过保留假内插器的输入来“知道”旋转动画停止的位置,并在ViewSwitcher调用startAnimation时将其恢复,但旋转动画中仍存在“跳跃”!
我该如何让ImageView始终在旋转,并且添加并移除来自ViewSwitcher/ViewAnimator的正确输入/输出动画而不停止旋转动画?
非常感谢!
您使用的是'ImageView'作为'ViewSwitcher'的直接子(被放置在res /动画)? – Luksprog
是的确...... hooo这是一个好主意...... – galex
尝试在另一个布局中包装它,比如'FrameLayout'。 – Luksprog