Reputation: 47
I have a TextView, and I wonder if there is a way to set alpha (opacity) for both text and image in a TextView programmatically. I found 'alpha' property in TextView properties, it affects to text of the TextView but will it affect to image in the TextView too? How do I do it programmatically?
Upvotes: 1
Views: 7142
Reputation: 1672
your_variable_name.setALpha(0f);
f = float
0f means 0%
1f means 100%
0.8f means 80%
You can use setAlpha() in ImageViews also.
If you want to smooth the process(use an animation) :
your_variable_name.animate().alpha(0f).setDuration(300);
300 is millis that means 1000 = 1 sec
Upvotes: 10
Reputation: 1710
You can wrap your views in a ViewGroup (FrameLayout,RelativeLayout ...
) and call viewGroup.setAlpha(yourValue)
Upvotes: 0