【发布时间】:2011-02-02 15:14:06
【问题描述】:
我已经为几乎所有的小部件指定了白色背景,并且它可以工作,除了滚动时。背景容器在滚动过程中变黑,导致烦人的闪烁。
【问题讨论】:
标签: android listview scroll colors
我已经为几乎所有的小部件指定了白色背景,并且它可以工作,除了滚动时。背景容器在滚动过程中变黑,导致烦人的闪烁。
【问题讨论】:
标签: android listview scroll colors
只需将背景放在顶部,没有高亮或其他不良效果简单,无需提示或缓存
在列表视图布局中
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>
【讨论】:
我通过使单元格的背景颜色与 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>
这完全解决了我的问题,似乎是最好的解决方案
【讨论】:
【讨论】:
您的活动的 *.xml 文件中的列表对象的 ScrollingCache="false" 也应该可以解决问题。
【讨论】: