java如何暂停和恢复动画?
我有一个圆形图像视图,我可以通过单击按钮开始旋转它,但我想在它停止在该位置时再次按下按钮。我该怎么做
这是Animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:interpolator="@安卓:anim/linear_interpolator">
<rotate
安卓:fromDegrees="0"
安卓:pivotX="50%"
安卓:pivotY="50%"
安卓:toDegrees="360"
安卓:duration="10000"
安卓:repeatCount="infinite"
安卓:repeatMode="restart" />
</set>
这是MainActivity
Animation cd1;
ImageView imageview;
Button button1;
cd1 = AnimationUtils.loadAnimation(this, R.anim.cd_player1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageview.startAnimation(cd1);
}
}
});
谢谢!
# 1 楼答案
试着这样
这取决于你想在onclick中调用什么