Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set an Android View's transparency with animation?

I need to set the initial transparency for a TextView, but I don't know how to do it. On iPhone/iOS, it can be done easily with the alpha property. On Android, I've tried to set the alpha using AlphaAnimation but it's no good -- it doesn't work. It just returns to 100% alpha when the animation ends.

AlphaAnimation anim = new AlphaAnimation(1, 0.2f);
anim.setDuration(5000);
textView.startAnimation(anim);

Any ideas guys?

like image 514
Kostia Dombrovsky Avatar asked Feb 01 '10 22:02

Kostia Dombrovsky


1 Answers

You can set the alpha channel directly in a color value that you assign to the TextView. See Available Resource Types.

like image 199
RickNotFred Avatar answered Sep 26 '22 00:09

RickNotFred