ListView redraws the background color whenever I scroll

I defined a custom theme where I draw a dark gradient on my window background. My ListView background is set to transparent, however whenever I scroll, the background color turns black, and then after scrolling returns 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>
+3
source share
2 answers

Your question will be answered: http://developer.android.com/resources/articles/listview-backgrounds.html You just need to install cacheColorHintto fix your problem. :-)

+11
source

cacheColorHint = "# 00000000" xml listView

<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>

U   this.getListView.setCacheColorHint(0);

+1

Source: https://habr.com/ru/post/1766281/


All Articles