user4004871
user4004871

Reputation:

Android animation on textview

I want to do an infinite animation on my textview. But it doesnt work! This is my animation xml

<alpha
    android:duration="1000"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toAlpha="1.0" />

<alpha
    android:startOffset="1000"
    android:duration="1000"
    android:fromAlpha="1.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toAlpha="0.0" />

and this is my code in my activity

void animation(){

    Animation anim1 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animationtext);
    tviPrueba.startAnimation(anim1);
    anim1.setRepeatCount(Animation.INFINITE);

}

Upvotes: 1

Views: 926

Answers (2)

Aakash
Aakash

Reputation: 5261

Animation anim1 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animationtext);
anim1.setRepeatCount(Animation.INFINITE);
tviPrueba.startAnimation(anim1);

Upvotes: 0

Mariano Zorrilla
Mariano Zorrilla

Reputation: 7686

Don't complicate yourself... if is infinite, use the reverse mode:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
    android:fromAlpha="0.0"
    android:toAlpha="1.0"
    android:duration="1000" 
    android:repeatMode="reverse"
    android:repeatCount="infinite" />
</set>

remove the anim1.setRepeatCount(Animation.INFINITE); line and use my xml

Upvotes: 3

Related Questions