开发者

ListView redraws background color whenever I scroll

开发者 https://www.devze.com 2023-01-17 14:06 出处:网络
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,

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">
        <ite开发者_如何学Pythonm name="android:windowBackground">@drawable/dark_gradient</item>

      </style>

    </resources>


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. :-)


Just set cacheColorHint="#00000000" in your xml listView its a transparent color

<ListView android:id="@id/android:list" android:layout_width="320dp"
android:layout_height="fill_parent" android:layout_centerHorizontal="true"
android:divider="@color/whitetxtcolor"
android:layout_weight="2" android:drawSelectorOnTop="false"     
android:layout_below="@id/new_layout"
android:cacheColorHint="#000000"
></ListView>

or U can do like this also this.getListView.setCacheColorHint(0);

0

精彩评论

暂无评论...
验证码 换一张
取 消