在我为 View
设置动画后,如何获得它的 alpha/opacity?
我的 fadeIn()
如下 - fadeOut()
与端点切换相同。
public void fadeIn(View view) {
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(1000);
animation.setFillAfter(true);
view.startAnimation(animation);
}
最佳答案
我强烈建议您在 XML 文件中定义动画。 API 不支持获取特定的 alpha。
您仍然可以记住,您的 View 具有的不透明度是您定义的最后一个;在这种情况下,(您的 fadeIn()
方法),您最新的不透明度值是您传递给 AlphaAnimation
构造函数的值。
关于java - 在 Android 中获取 View 的 alpha/不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3587977/