滚动时 Android ListView 背景颜色更改 - colorCacheHint 未修复问题

标签 android listview background-color

所以我通过适配器使用自定义 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/

相关文章:

css - 使用 CSS 为背景图像添加色调

css - 在没有jquery的情况下更改页面滚动时的背景颜色?

reactjs - React Native 需要点击两次 onPress 才能工作

listview - Xamarin Forms更改ListView中每个ViewCell的背景颜色

android subview 忽略父填充

android - 我得到 'android.content.res.Resources android.content.Context.getResources()'

android字符串长度和格式?

java - Android 的 getBSSID() 方法错误?

android - 如何在 ExpandableList 中使用 ListView?