我需要对ListView进行样式设计,但是当滚动时它会变成黑色背景,我不知道为什么。我的ListView在LinearLayout中,而该布局的背景设置为图像。
这是我为ListView拥有的内容:
<style name="MyListView" parent="@android:style/Widget.ListView">
<item name="android:listSelector">@drawable/selector_list_item</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@drawable/shape_list_item_normal" />
<item android:state_pressed="true"
android:drawable="@drawable/shape_list_item_pressed" />
<item android:state_focused="true"
android:drawable="@drawable/shape_list_item_normal" />
</selector>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#80ffffff" android:endColor="#80eff3ef" android:angle="45" />
<padding android:left="5dip" android:right="5dip" android:top="7dip" android:bottom="7dip"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#80808080" android:endColor="#80eff3ef" android:angle="45" />
<padding android:left="5dip" android:right="5dip" android:top="7dip" android:bottom="7dip"/>
</shape>
当我应用MyListView样式时,我看不到太多变化。当我点击项目时 - 是的,我看到了渐变效果。当ListView稳定时 - 我看到的背景与父布局中的应该一样。当我滚动时 - 我看到黑色背景,它正在擦除父布局的背景。如果我知道如何使用其他东西来设置它,那么这对我来说就没问题了。