0

我得到“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);
            }
4

1 回答 1

0

如果您阅读文档,您会看到该类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);
}
于 2012-09-28T11:51:39.890 回答