Android listview 取消选中效果

场景:
Android listview系统自带了点击item效果,如果item是圆角背景样式的时候,会发现点击item时,默认点击效果是方形的,这样很不好看。那么怎么取消选中效果呢?
解决:
在listview的布局文件中加入:
android:listSelector=”@android:color/transparent”
这样就给点击效果的默认颜色为透明色

    <ListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_marginRight="30dp"
        android:layout_marginLeft="30dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:divider="#00000000"
        android:listSelector="@android:color/transparent"/>

猜你喜欢

转载自blog.csdn.net/gowater123/article/details/80904318