Android关闭ListView,ScrollView等自带的蓝色荧光效果

来源:互联网 发布:java读取动态日志文件 编辑:程序博客网 时间:2024/04/30 02:26

在xml文件中添加属性

  android:fadingEdge="none"


但是这条属性在API8之后就无效了, 所以还要创建一个类来继承ListView或ScallView

在构造函数中加入

if (Build.VERSION.SDK_INT >= 9) {
this.setOverScrollMode(View.OVER_SCROLL_NEVER);
}


代码如下:

public class MyListView extends ListView {public MyListView(Context context) {super(context);if (Build.VERSION.SDK_INT >= 9) {this.setOverScrollMode(View.OVER_SCROLL_NEVER);}}public MyListView(Context context, AttributeSet attrs) {super(context, attrs);if (Build.VERSION.SDK_INT >= 9) {this.setOverScrollMode(View.OVER_SCROLL_NEVER);}}}





0 0