Getting alpha/opacity of a View in Android
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);
an开发者_如何学Pythonimation.setDuration(1000);
animation.setFillAfter(true);
view.startAnimation(animation);
}
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.
精彩评论