Scroll上的Android ListView背景颜色更改 - colorCacheHint无法解决问题

Pau*_*uiz 5 android listview background-color

所以我通过适配器使用自定义列表视图,在我的Nexus 7上,一切看起来都很棒,但在我的HTC Incredible 2上,我遇到了我的背景颜色发生变化的问题.这是我的cacheColorHint设置的XML文件.我也试过#AA00000.有什么建议?我也尝试通过setCacheColorHint在活动中设置它,但还没有任何工作.

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"     
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:padding="10dp"
 android:background="#AA000000"
 android:cacheColorHint="#00000000">

 <ImageView android:id="@+id/ExhibitListIcon"
 android:contentDescription="Exhibit List Icon"
 android:layout_width="wrap_content"
 android:layout_height="fill_parent"
 android:gravity="center_vertical"
 android:layout_marginRight="15dp"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp" />

 <TextView android:id="@+id/ExhibitListTitle"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="center"
 android:textStyle="bold"
 android:textSize="22dp"
 android:textColor="#FFFFFF"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp" />

 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Abh*_*wal 21

您可以尝试在声明Listview的xml中设置cachecolorhint,而不是LinearLayout:

在布局文件中,使用:

android:cacheColorHint="#0000"
Run Code Online (Sandbox Code Playgroud)

或者在java代码中,使用

listView.setCacheColorHint(Color.TRANSPARENT);
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!!


Muk*_*mar 6

在列表视图中添加以下行:

android:cacheColorHint ="@ android:color/transparent"