I need to set alpha for a view. It is ImageButton and on Touch event i want to set alpha that i could see it was pressed. Maybe there some work around on this ? It don't suit me changing background color. Because my background is image and i wan't to change alpha of this image. Also i don't want to use selectors because my images are created dynamically.
Finally if there are no way to do this. So how i could catch exception that it setAlpha isn't supported for Api phone is using ?
Thanks
I found this snippet of code some time ago. Maybe it will help?
if (Build.VERSION.SDK_INT < 11) {
final AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
animation.setDuration(duration);
animation.setFillAfter(true);
view.startAnimation(animation);
} else
view.setAlpha(alpha);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With