2016-03-19 3 views
0

anwendet, arbeite an android Anwendung und ich möchte Animation auf meinem Projekt. Ich habe einige Taste und Bild Jetzt i-Animation auf diese Schaltfläche hinzufügen möchten, wie kann ich diese implementieren bitte helfen Sie mir, wie man Animation auf Knopf in 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

ich denke, es gibt keine Notwendigkeit –

+0

dann zu setzen OnClickListener zu verwenden ist, was ich benutze bitte helfen Sie mir – Harry

+0

@Harry hier zu finden: - http://coderzpassion.com/android-working-animation/ –

Antwort

0

dieser Code ist

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 Ihrem anim Ordner, um es als XML einfügen

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" /> 
+0

lassen Sie mich bitte überprüfen – Harry

+0

was ist das (R.anim.anticlock) – Harry

+0

Machen Sie einen Ordner Anim in Ihrem resourece gut –

Verwandte Themen