Android - ListView list selector doesn't use default
I'm using my own selector for my ListView, but the default is not used. How are you supposed to set the d开发者_JS百科efault background drawable? With the below code I'd expect all of my list rows to be blue until focused or pressed.
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<gradient
android:startColor="#0266e9"
android:endColor="#0484f2"
android:angle="90" />
</shape>
</item>
<item android:state_focused="true" >
<shape>
<gradient
android:startColor="#bbccff"
android:endColor="#dce4fd"
android:angle="90" />
</shape>
</item>
<item>
<shape>
<solid android:color="#FF0000FF"></solid>
</shape>
</item>
</selector>
Could be that the default (the blue) is not visible: http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html#attr_android:visible
According to the document the visibility is initially false.
精彩评论