所以我通过适配器使用自定义 ListView ,在我的 Nexus 7 上一切看起来都很棒,但在我的 HTC Incredible 2 上我遇到了背景颜色发生变化的问题。这是我的 XML 文件,其中设置了 cacheColorHint。我也试过#AA00000。有什么建议么?我还尝试通过 setCacheColorHint 在 Activity 中设置它,但还没有任何效果。
<?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>
最佳答案
您可以尝试在声明 Listview 的 xml 中设置 cachecolorhint,而不是 LinearLayout :
在布局文件中,使用:
android:cacheColorHint="#0000"
或者在java代码中,使用
listView.setCacheColorHint(Color.TRANSPARENT);
希望这对您有所帮助!
关于滚动时 Android ListView 背景颜色更改 - colorCacheHint 未修复问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13673252/