我有一个带有一些项目的ListView或PreferenceView(例如5个)
每个元素都有android:background
值
android:background="@drawable/red_selector_list"
red_selector_list:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/red_gradient" />
<item android:state_focused="true" android:drawable="@drawable/red_gradient" />
<item android:state_pressed="true" android:drawable="@drawable/red_gradient" />
<item android:drawable="@drawable/gray_gradient_list" />
</selector>
red_gradient:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#990000"
android:centerColor="#b00000"
android:endColor="#ff0000"
android:type="linear" />
<corners android:radius="0dp"/>
</shape>
gray_gradient_list:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:angle="90" android:startColor="#ebebeb"
android:endColor="#ffffff" android:type="linear" />
<corners android:radius="0dp"/>
</shape>
重现此问题的步骤:
在同时选择两个项目后始终保持高亮显示并且应该消失。对于没有android:background
值的项目,无法重现此问题。它可能是Android平台问题吗?