Подтвердить что ты не робот

Повторить андроидную анимацию

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);
}

Я хочу повторить эту анимацию анимации textview, пока не получит информацию о GPS

4b9b3361

Ответ 1

Как этот.

animation.setRepeatCount(Animation.INFINITE);

Ответ 2

Вы можете сделать это

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

Ответ 3

Android предоставляет вам элегантные механизмы для представления процесса загрузки. Вы можете использовать неопределенный ProgressBar или ImageView с анимацией scale/alpha вместо анимации самой TextView.

Возможно, вы можете найти эту анимацию полезной, для анимации альфы и масштаба одновременно. Измените параметры для своих предпочтений:

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>

затем запустите его в коде:

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

И чтобы остановить его:

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

Вы также можете использовать библиотеки, такие как ProgressButtonView, чтобы поддерживать как взаимодействие с пользователем, так и процесс загрузки в одном и том же виджете.

Надеемся, что любое из этих решений окажется полезным для кого-то:)

Ответ 4

fadeIn.setRepeatCount(int count)

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

вы можете использовать эти методы для управления повторением.

реализовать это при необходимости

    //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)
            {


            }
        });

Если вы хотите остановить свою анимацию suddennly. используйте myview.clearAnimation() Я надеюсь, что это поможет.