首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ListView背景变化onFling

ListView背景变化onFling
EN

Stack Overflow用户
提问于 2012-03-13 06:18:05
回答 2查看 696关注 0票数 2

我在一个LinearLayout中有两个LinearLayout。LinearLayout的背景是可绘制的。一切都很好,但是当我使用任何一个ListView时,背景图像就会消失,黑色的背景就会显示出来。当fling停止时,图像将再次显示为背景。我不想改变背景,我做错什么了吗?

布局如下:

代码语言:javascript
复制
<LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
    <TextView 
        android:text="Upcoming Trips"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/top_blue_box"
        android:textColor="#ffffff"
        android:textStyle="bold"
        android:textSize="16sp"
        android:layout_gravity="center"
        />
    <ListView 
        android:id="@+id/upList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_gravity="center_vertical"
        android:layout_weight="2"           
        />
    <TextView 
        android:text="Past Trips"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bottom_box"
        android:textColor="#ffffff"
        android:textStyle="bold"
        android:textSize="16sp"
        android:layout_gravity="center_horizontal"
        />
     <ListView 
        android:id="@+id/downList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_gravity="center_vertical"
        android:layout_weight="2"           
        />
    </LinearLayout>

编辑:解决方案是详细解释这里的,这要感谢罗宾汉。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-03-13 06:21:14

使用

代码语言:javascript
复制
listView.setCacheColorHint(Color.TRANSPARENT);

在爪哇或

代码语言:javascript
复制
android:cacheColorHint="#00000000"

在xml中的ListView标记

票数 4
EN

Stack Overflow用户

发布于 2012-03-13 06:21:46

向列表视图应用与布局颜色相同的颜色缓存提示。

示例:

代码语言:javascript
复制
android:cacheColorHint="light blue"

缓存颜色提示

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9679222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档