[英]how to implement animation on Button in android
Am working on android application and i want to animation on my project. 我正在开发android应用程序,我想在我的项目中制作动画。 i have some button and image view now i want to add animation on these button how can i implement these please assist me
我现在有一些按钮和图像视图,我想在这些按钮上添加动画,我该如何实现这些,请协助我
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
}
}
});
this is code 这是代码
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();
}
});
In your anim folder paste it as a xml 在您的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" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.