ple*_*ock 20 android android-listview
边框显示默认颜色(在我的Nexus S上为橙色),同时将ListView滚动到限制.如何改变那种颜色?
我真的不知道如何解释它.看看这张图:

那么,当ListView滚动到边框时如何更改高亮颜色?使用主题或样式
lou*_*uio 47
解决方案是使用setOverscrollFooter(null)和setOverscrollHeader(null).文档在这里!
您也可以直接在XML中设置它:
<ListView android:overScrollMode="never" />
Run Code Online (Sandbox Code Playgroud)
或者指定页脚和标题:
<ListView
android:overscrollHeader="@null"
android:overscrollFooter="@null" />
Run Code Online (Sandbox Code Playgroud)
注意:还有一个fadingEdge可能让您感兴趣的房产.
启动API级别9支持"Overscroll"方法
最后我找到了解决方案.
setOverscrollFooter(null)并且setOverscrollHeader(null)不起作用.至少在2.3.*.从*.xml设置属性也没有用.setOverScrollMode(View.OVER_SCROLL_NEVER)导致毛刺滚动.至少在2.3.*.唯一真正有效的解决方案是使用Java Reflection.它甚至可以用丑陋的自定义三星列表视图和弹跳过度滚动效果.这是一个片段:
@Override
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
//onOverScrolled method must be overrided, or we will see the background of the listview when overscroll fast.
}
private void removeOverscrollEffect() {
try {
Class<?> superClass = getClass().getSuperclass().getSuperclass();
Field field = superClass.getDeclaredField("mEdgeGlowTop");
field.setAccessible(true);
Object edgeGlowTop = field.get(this);
if (edgeGlowTop != null) {
Class<? extends Object> edgeClass = edgeGlowTop.getClass();
Field edgeDrawable = edgeClass.getDeclaredField("mEdge");
edgeDrawable.setAccessible(true);
edgeDrawable.set(edgeGlowTop, new ColorDrawable(Color.TRANSPARENT));
Field glowDrawable = edgeClass.getDeclaredField("mGlow");
glowDrawable.setAccessible(true);
glowDrawable.set(edgeGlowTop, new ColorDrawable(Color.TRANSPARENT));
field.set(this, edgeGlowTop);
}
Field fieldBottom = superClass.getDeclaredField("mEdgeGlowBottom");
fieldBottom.setAccessible(true);
Object edgeGlowBottom = fieldBottom.get(this);
if (edgeGlowBottom != null) {
Class<? extends Object> edgeClassBottom = edgeGlowBottom.getClass();
Field edgeDrawableBottom = edgeClassBottom.getDeclaredField("mEdge");
edgeDrawableBottom.setAccessible(true);
edgeDrawableBottom.set(edgeGlowBottom, new ColorDrawable(Color.TRANSPARENT));
Field glowDrawableBottom = edgeClassBottom.getDeclaredField("mGlow");
glowDrawableBottom.setAccessible(true);
glowDrawableBottom.set(edgeGlowBottom, new ColorDrawable(Color.TRANSPARENT));
fieldBottom.set(this, edgeGlowBottom);
}
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助.