简体   繁体   English

(Android)listview分隔符已删除,但单击后仍显示蓝线

[英](Android)listview divider removed, but still show blue line after click

I have a listview in a LinearLayout, and i have removed its divider in xml, like this: 我在LinearLayout中有一个listview,并且已经在xml中删除了它的分隔符,如下所示:

   <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="140dp"
        android:orientation="vertical"
        android:background="@drawable/main_content">
        <ListView 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:cacheColorHint="@null"
            android:divider="@null"
            android:dividerHeight="0dp"/>
     </LinearLayout>

The problem is, everytime when i click an item, a blue line will show up above the item just like a divider exists there. 问题是,每当我单击一个项目时,都会在该项目上方显示一条蓝线,就像那里存在分隔线一样。 Then if i click somewhere else, the line goes away. 然后,如果我单击其他地方,线就会消失。 How can i stop this from happening? 我该如何阻止这种情况的发生?

use list Selector property as below: 使用列表选择器属性,如下所示:

android:listSelector="#00000000"

you can set it to null as well. 您也可以将其设置为null。 i have set it to transparent. 我将其设置为透明。

Add these two lines inside your listview 将这两行添加到列表视图中

android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"

and delete 并删除

android:cacheColorHint="@null"
android:divider="@null"
android:dividerHeight="0dp"

use 采用

<ListView 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM