Getting alpha/opacity of a View in Android

By : Justin
Source: Stackoverflow.com
Question!

How can I get the alpha/opacity of a View after I've animated it?

My fadeIn() is below - fadeOut() is the same with the endpoints switched.

public void fadeIn(View view) {
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(1000);
    animation.setFillAfter(true);
    view.startAnimation(animation);
}
By : Justin


Answers

I would highly recommend you to define the animations in an XML-file. The API doesn't have support for getting a specific alpha.

You can still have in mind that the opacity that your view has, is the last one you've defined; in this case, (your fadeIn() method), your latest opacity value is the value you passed into the AlphaAnimation constructor.

By : Wroclai


This video can help you solving your question :)
By: admin