views:

66

answers:

1

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);
}
+1  A: 

I would highly recommend you to define the animations in an XML-file. The API does not 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 have defined; in this case, (your fadeIn method), your latest opacity value is that value you passed into the AlphaAnimation constructor.

Charlie Sheen