我在android 2.3.3上有一个ListView背景问题(android 4没问题)。单击列表项时,将ListView背景从@color/holo_green
属性更改为android:listSelector
。如何解决这个问题?
my_list.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
android:alwaysDrawnWithCache="false"
android:cacheColorHint="@android:color/transparent"
android:listSelector="@drawable/sa_list_item_selector"
android:divider="@drawable/sa_list_divider"/>
添加android:background="@android:color/transparent"
无变化
sa_list_item_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/holo_green" />
<item android:drawable="@android:color/transparent" />
</selector>
答案 0 :(得分:0)
也许尝试改变:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/holo_green" />
<item android:drawable="@android:color/transparent" />
</selector>
要:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@android:color/transparent" />
<item android:drawable="@color/holo_green" />
</selector>
看看你的选择器。代码在那里。