android - 为什么触摸 ListView 时我的 CheckBox 的背景颜色会改变?

标签 android checkbox android-listview background-color

我有一个自定义 ListView,其中每个 row.xml 如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:orientation="horizontal" >

<CheckBox
    android:id="@+id/star_listed"
    style="?android:attr/starStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:contentDescription="@string/question_img_cd"
    android:focusable="false"/>

<TextView
    android:id="@+id/listTitles"
    style="@style/ListTitles" />

一切正常,除了当我按下 ListView 上的任意位置时,CheckBox 的背景变为黑色(而不是保持白色)。在我将其背景颜色设置为白色之前,它也发生在我的 TextView 上。

row.xml

如果我将“CheckBox”背景更改为白色,甚至透明,它就会消失。

有什么建议吗?

最佳答案

我不确定,但这可能会发生,因为您使用了具有透明背景(我不确定)的星号 (?android:attr/starStyle) 的默认样式属性,并且您会看到底层的黑色行颜色。尝试为行中的父 LinearLayout 设置白色,而不是为行中的每个 View 设置颜色。

关于android - 为什么触摸 ListView 时我的 CheckBox 的背景颜色会改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10649751/

相关文章:

android - 在 Android 中嵌入 OSGi Felix 导致 UnsupportedOperationException : can't load this type of class file

Android API 21+ - 以编程方式在 TimePickerDialog 中隐藏模拟时钟

gridview - 如何处理 Yii2 gridview 中的复选框列?

javascript - 通过选中复选框启用多个输入

android - 使用异步任务加载图像时 Android ListView 中的奇怪行为

android - Listview到达末尾后反向滚动?

android - 如何在 Android 的 PreferenceFragment 中添加进度条?

android - 了解用于从 Android 使用 .Net Web 服务的 SSL

Angular 中的图像作为复选框

android - 如何为在 ListView 中动态添加的项目创建 Activity ?