本文介绍了如何设置查看阿尔法在较低的空气污染比11?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置阿尔法的看法。它的ImageButton和触摸事件我想设置阿尔法,我可以看到它是pressed。也许有一些工作围绕这个?它不适合我改变背景颜色。因为我的背景是形象和我wan't改变这一形象的阿尔法。此外,我不希望使用选择,因为我的图片是动态创建的。

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.

最后,如果没有办法做到这一点。那么如何,它不支持阿比电话setAlpha我能赶上的异常使用?

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 ?

感谢

推荐答案

我发现这个片段$ C $了C前一段时间。也许这将帮助?

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);
}

这篇关于如何设置查看阿尔法在较低的空气污染比11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 11:16