views:

944

answers:

2

For some reason, whenever I scroll through my list of items, the background inside my listview disappears and reappears giving rise to a "flicker" effect which I don't really want. I've tried the suggestion at: http://stackoverflow.com/questions/1377336/android-make-listview-transparent but it doesn't work for some reason. Any suggestions?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/screenLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    >
        <TextView
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="center"
         android:background="@color/title_background"
         android:text="@string/whatsnew_title"
         >
        </TextView>
        <ListView
      android:id="@android:id/list"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
     </ListView>  
</LinearLayout>
+1  A: 

Check your theme.xml for <item name="android:windowBackground">@null</item>. If you have it - remove it. I think one of the popular resources gives this line as example (that's how I got mine).

DroidIn.net
I actually don't have a custom theme.xml. Are you suggesting that I create one?
Legend
You may try that - I had a similar issue with my preferences screen (which is ListView) but then - I did have custom theme.xml and the entry I have in my answer
DroidIn.net
+2  A: 

Did you include android:cacheColorHint="#00000000"? It's the most important part of the proposed fix. I've just tried your code (obviously not an exact reproduction, as you're using references to project-specific resources) with it, and it seems to work.

This post on the Android Developers blog should be of your interest.

mernen
Awesome... You wouldn't believe me... I tried attaching cacheColorHint but every resource I found said android:cacheColorHint="#000000" (notice the number of zeroes apparently saying nothing about alpha)... And now it works exactly as I wanted it to... Thanks a lot!
Legend