0

按下时截图

在我的 Android 应用程序中,当用户按下列表中的某个项目时,该项目正确地以蓝色突出显示,但列表中的所有其他项目也以灰色突出显示。当用户抬起手指时,高光就会消失。这会导致整个列表出现不希望出现的“闪烁”效果。

如果我只从 ListView 中删除背景属性,闪烁效果就会消失。我正在寻找另一个修复程序,以便保留背景属性。

我使用的是安卓 17。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="8dip"
    android:paddingTop="0dip"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:textColor="@color/my_sky"
        android:background="@drawable/my_btn_white"
        android:id="@+id/my_list"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"/>

    <Button
        style="@style/MY.Flow.Button"
        android:id="@+id/my_add_choices"
        android:text="@string/my_favorites_add_choices"
        android:layout_marginTop="10dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>
4

2 回答 2

1

我发现了问题。我的@drawable/my_btn_white 有以下行:

<item android:state_pressed="true" android:drawable="@drawable/my_btn_white_active"/>

当我删除这条线时,灰色突出显示以及闪烁消失了。

于 2013-10-24T17:22:23.103 回答
0

尝试添加到您的ListView

android:cacheColorHint="@android:color/transparent"
于 2013-10-24T16:39:14.777 回答