Stu Whyte
Stu Whyte

Reputation: 768

Simple Android alpha animation reversing when not declared

I am trying to create a simple fade out effect on a TextView. Having looked around SO, I couldn't see a similar issue posted.

I have a simple fade_out.xml

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="500"
    android:fromAlpha="1.0"
    android:toAlpha="0.0" />

And start the animation as so,

Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out);
textView.startAnimation(fadeOut);

The issue is that the TextView succesfully fades out, but it fades back in again. I must be missing something simple?

Upvotes: 0

Views: 85

Answers (1)

Alex Salauyou
Alex Salauyou

Reputation: 14348

Add android:fillAfter="true". This will force a view to remember its state after animation finishes.

Upvotes: 2

Related Questions