Мои фоны ListView становятся черными во время прокрутки - как это исправить? - PullRequest
16 голосов
/ 30 марта 2010

Я указал белый фон почти для всех виджетов, и он работает, за исключением прокрутки. Во время прокрутки фоновый контейнер становится черным, что вызывает раздражающее мерцание.

Ответы [ 4 ]

54 голосов
/ 30 марта 2010

Вам нужно будет использовать setCacheColorHint() метод ListView.

Пример: list.setCacheColorHint(yourBackColor);

Объяснение вопроса и решения здесь

4 голосов
/ 31 марта 2010

ScrollingCache = "false" в файле * .xml вашей деятельности для объекта списка тоже должно помочь.

0 голосов
/ 27 июня 2013

Я исправил эту проблему, сделав цвет фона ячеек таким же, как у ListView, поэтому:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#FFFFFF">

    <ListView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FFFFFF"> <---- Background color of ListView
    </ListView>
</LinearLayout>

и затем строка:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="8dip"
    android:background="#FFFFFF"> <--- Background color of the cell

    <LinearLayout 
        android:id="@+id/projects_cover_row_image_layout"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:background="#444444"
        android:layout_centerInParent="true"
        android:layout_marginRight="8dip">

        <ImageView 
            android:id="@+id/projects_cover_row_image"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:contentDescription="@string/projects_image_content"/>
    </LinearLayout>

    ...

</RelativeLayout>

, что полностью избавило меня от проблемы и кажется лучшим решением

0 голосов
/ 25 февраля 2013

Просто поместите фон в верхнюю часть экрана и не выделяйте подсветку или другие плохие эффекты просто и не нужно подсказок или кеша в макете списка android:background="#000000" для черного фона или android:background="#FFFFFF" для белого

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/testscheck"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:layout_marginBottom="12dp"
        android:layout_weight="1"
        android:layout_gravity="left|center"
        android:gravity="left"
        android:textColor="@color/ics"
        android:textSize="14sp"
         />
</LinearLayout>
...