小编Bin*_*Cao的帖子

如何暂停和恢复动画?

我有一个圆形 Imageview,我可以通过单击按钮开始旋转它,但是当它停在那个位置时我想再次按下按钮。我怎样才能做到这一点?

这是 Animation

 <?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
    <rotate
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="360"
        android:duration="10000"
        android:repeatCount="infinite"
        android:repeatMode="restart" />
 </set>
Run Code Online (Sandbox Code Playgroud)

这是 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);
                }
            }
        });
Run Code Online (Sandbox Code Playgroud)

谢谢 !

java animation android imageview

2
推荐指数
1
解决办法
2443
查看次数

标签 统计

android ×1

animation ×1

imageview ×1

java ×1