我正在开发Android应用程序,我想在我的项目上动画。我有一些按钮和图像视图现在我想在这些按钮上添加动画我该如何实现这些请帮助我
enter code here
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Btn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}
});
答案 0 :(得分:0)
这是代码
enter code here
final Animation an = AnimationUtils.loadAnimation(getBaseContext(), R.anim.anticlock);
btn.startAnimation(an);
an.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
iv.startAnimation(an);
finish();
}
});
在anim文件夹中将其粘贴为xml
enter code here
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1500"
android:fromDegrees="360"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="0" />