转载地址 :http://www.android100.org/html/201305/24/2734.html
方法一,在控件被初始化的时候设置
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"/>
当然也可以定制化自己想要的效果。推荐使用方法二,解耦逻辑代码与布局文件。
本文介绍两种方法设置GridView和ListView的选择器为透明,一种是在代码中初始化控件时直接设置,另一种是在XML布局文件中通过listSelector属性指定颜色资源。

6059

被折叠的 条评论
为什么被折叠?



