我得到了"ALPHA_THRESHOLD无法解析或者不是ViewConfiguration的字段“,我的代码如下
// If the view has 0 alpha, we set it to be invisible so as to prevent
// it from accepting touches
if (alpha < ViewConfiguration.ALPHA_THRESHOLD) {
v.setVisibility(INVISIBLE);
} else if (v.getVisibility() != VISIBLE) {
v.setVisibility(VISIBLE);
}发布于 2012-09-28 19:51:40
如果您阅读docs,您可以看到ViewConfiguration类没有任何可访问的公共常量。
如果你阅读源代码,你会发现ALPHA_THRESHOLD是隐藏的(使用@hide注解)。
/**
* Minimum alpha required for a view to draw.
*
* @hide
*/
public static final float ALPHA_THRESHOLD = 0.5f / PANEL_BIT_DEPTH;也就是PANEL_BIT_DEPTH = 24
我对你尝试做什么没有经验,或者它是否正确,但你可以用以下代码替换你的代码:
final static float ALPHA_THRESHOLD = 0.5f / 24;
if (alpha < ALPHA_THRESHOLD) {
v.setVisibility(INVISIBLE);
} else if (v.getVisibility() != VISIBLE) {
v.setVisibility(VISIBLE);
}https://stackoverflow.com/questions/12638976
复制相似问题