2013-02-22 14 views
27
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.vitesse); 

    gpsManager = new GPSManager(); 

    gpsManager.startListening(getApplicationContext()); 
    gpsManager.setGPSCallback(this); 
    Typeface tf = Typeface.createFromAsset(getAssets(), 
      "font/DS-DIGI.TTF"); 
    TextView loding =(TextView)findViewById(R.id.info_message); 
      loding.setTypeface(tf); 
      AlphaAnimation fadeIn = new AlphaAnimation(0.0f , 1.0f) ; 
      AlphaAnimation fadeOut = new AlphaAnimation(1.0f , 0.0f) ; 
      loding.startAnimation(fadeIn); 
      loding.startAnimation(fadeOut); 
      fadeIn.setDuration(500); 
      fadeOut.setDuration(1200); 
      fadeOut.setStartOffset(1200+fadeIn.getStartOffset()+1200);  
      measurement_index = AppSettings.getMeasureUnit(this); 
} 

chcę powtórzyć to z TextView animacji wyleganie aż GöTTING się inforamtion z GPSPowtórz android animacja

Odpowiedz

71

Jak this.

animation.setRepeatCount(Animation.INFINITE); 
+0

thank Alex to działa dobrze :) – EMIN

+0

Cheers, to zwykle przyjąć prawidłową odpowiedź chociaż. – alex

5
fadeIn.setRepeatCount(int count) 

fadeIn.setRepeatMode(AlphaAnimation.INFINITE(or any other repeat mode reletaed yo your usage)) 

można użyć tych metod do kontrolowania powtórki.

zaimplementować to w razie potrzeby

//anim = your animation 


anim.setAnimationListener(new AnimationListener() 
     { 

      public void onAnimationStart(Animation arg0) 
      { 
       // TODO Auto-generated method stub 

      } 


      public void onAnimationRepeat(Animation arg0) 
      { 
       // TODO Auto-generated method stub 

      } 

      public void onAnimationEnd(Animation arg0) 
      { 


      } 
     }); 

jeśli chcesz zatrzymać animację suddennly. użyj yourview.clearAnimation() Mam nadzieję, że to pomaga.

+0

[setRepeatMode] (http://developer.android.com/reference/android/view/animation/Animation.html#setRepeatMode (int)) oczekuje tylko RESTART lub REVERSE. INFINITE powinien być podany tylko dla setRepeatCount. –

10

Można to zrobić

animation.setRepeatCount(Animation.INFINITE); //Repeats animation indefinitely. 
+0

Działa dla mnie. Prosty i skuteczny – Bundeeteddee

8

Android daje eleganckie mechanizmy reprezentują proces ładowania. Możesz użyć nieokreślonego ProgressBar lub ImageView z animacją skali/alfa, zamiast animować samą siebie TextView.

Może ta animacja może być przydatna do animowania alfy i skali w tym samym czasie. Zmieniać parametry preferencjami:

file R.anim.alpha_scale_animation

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" > 
<scale 
    android:fromXScale="0.7" 
    android:toXScale="1.0" 
    android:fromYScale="0.7" 
    android:toYScale="1.0" 
    android:pivotX="50%p" 
    android:pivotY="50%p" 
    android:duration="4000" 
    android:repeatCount="infinite" 
    /> 

<alpha 
    android:fromAlpha="0.0" 
    android:toAlpha="1.0" 
    android:duration="2000" 
    android:repeatMode="reverse" 
    android:repeatCount="infinite" 
    /> 
</set> 

następnie uruchomić go w kodzie:

Animation connectingAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.alpha_scale_animation); 
myView.startAnimation(connectingAnimation); 

I żeby go zatrzymać:

myView.clearAnimation(); 
connectingAnimation.cancel(); 
connectingAnimation.reset(); 

Można również użyć biblioteki takie jak ProgressButtonView, aby zapewnić zarówno obsługę użytkownika, jak i proces ładowania n ten sam widget.

nadzieja, że ​​każde z tych rozwiązań spowodować przydatne dla kogoś :)

+0

Przyjemne dzięki – Sam