每当我滚动时,ListView 都会重新绘制背景颜色
我定义了一个自定义主题,在窗口背景上绘制深色渐变。我的 ListView 背景设置为透明,但是每当我滚动时,背景颜色就会变成黑色,然后在滚动停止后返回到渐变颜色。这是为什么呢?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme is the default theme. -->
<style name="Theme" parent="android:Theme">
</style>
<!-- Variation on our application theme that has a translucent
background. -->
<style name="Theme.DarkGradient">
<item name="android:windowBackground">@drawable/dark_gradient</item>
</style>
</resources>
I have defined a custom theme, where I am drawing a dark gradient on my window background. My ListView background is set to be transparent, however whenever I scroll, the background color turns black, and then after scrolling has stopped, goes back to the gradient color. Why is this?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme is the default theme. -->
<style name="Theme" parent="android:Theme">
</style>
<!-- Variation on our application theme that has a translucent
background. -->
<style name="Theme.DarkGradient">
<item name="android:windowBackground">@drawable/dark_gradient</item>
</style>
</resources>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题在这里得到解答: http://developer.android.com/resources/articles /listview-backgrounds.html
您只需设置
cacheColorHint
即可解决您的问题。 :-)Your question is answered here: http://developer.android.com/resources/articles/listview-backgrounds.html
You just need to set the
cacheColorHint
in order to fix your problem. :-)只需在您的 xml listView 中设置cacheColorHint =“#00000000”即可查看其透明颜色
,或者您也可以这样做
this.getListView.setCacheColorHint(0);
Just set cacheColorHint="#00000000" in your xml listView its a transparent color
or U can do like this also
this.getListView.setCacheColorHint(0);