Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: ListView Flicker effect. Any hints on how to get rid of this?

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: How to make a ListView transparent in Android? 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>
like image 363
Legend Avatar asked Oct 07 '09 18:10

Legend


3 Answers

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.

like image 56
mernen Avatar answered Oct 12 '22 23:10

mernen


This can also be achieved from Java (code) side: listView.setCacheColorHint(Color.TRANSPARENT);

like image 28
Suraj Bajaj Avatar answered Oct 12 '22 23:10

Suraj Bajaj


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

like image 40
Bostone Avatar answered Oct 13 '22 00:10

Bostone