方法一,在控件被初始化的时候设置

gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
listView.setSelector(new ColorDrawable(Color.TRANSPARENT));

方法二,在布局文件中设置listSelector属性

<GridView
        android:listSelector="@android:color/transparent"
        android:numColumns="auto_fit"
        android:columnWidth="50dp"
        android:stretchMode="spacingWidth"
        android:layout_weight="1.0"
        android:layout_height="0dip"
        android:layout_width="match_parent"/>

<ListView
        android:listSelector="@android:color/transparent"
        android:layout_height="match_parent"
        android:layout_width="match_parent"/>

当然也可以定制化自己想要的效果。

推荐使用方法二,解耦逻辑代码与布局文件。

 

本文转自:http://www.android100.org/html/201305/24/2734.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-07-30
  • 2021-09-14
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案