【发布时间】:2011-05-24 18:59:23
【问题描述】:
我需要设置 ListView 的样式,但不知道为什么滚动时它会变成黑色背景。我在 LinearLayout 中有 ListView,并且该布局的背景设置为图像。
这就是我拥有的 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 稳定时 - 我看到背景应该来自父布局。当我滚动时 - 我看到黑色背景,它正在擦除父母的背景。如果我知道如何用其他东西设置它,我会很好的..
【问题讨论】: