列表视图中的复选框样式不正确

Jus*_*ago 8 android android-listview android-checkbox android-styles

我在列表视图中显示的复选框中存在样式问题.我的应用使用的主题是Holo,但复选框以旧样式显示.出现在别处的复选框看起来很好.我没有做任何花哨的事情,比如创造我自己的风格.截图:

在此输入图像描述

复选框应该看起来像右图上的复选框.这是在v4.0.3上.复选框看起来应该在我尝试使用v4.4.2的其他设备上.

列表视图行的XML:

<?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" >

    <CheckBox android:id="@+id/ListRow_Task_TaskComplete" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="6sp"
        android:focusable="false" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingTop="7dip"
        android:paddingBottom="7dip"
        android:layout_toRightOf="@+id/ListRow_Task_TaskComplete"
        android:layout_centerVertical="true" >

        <TextView android:id="@+id/ListRow_Task_Name" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:textSize="16sp" />

        // next two textviews are programmatically hidden right now
        <TextView android:id="@+id/ListRow_Task_Deadline" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:text=""
            android:textSize="12sp" />

        <TextView android:id="@+id/ListRow_Task_Tags" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/icon_tag"
            android:drawablePadding="4dip"
            android:textSize="12sp" />  

    </LinearLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

如何使左侧的复选框看起来像它们应该的那样?

Sha*_*kti 3

将 Holo 复选框图像复制到所有 dpi 和分辨率的 android 可绘制文件夹中。然后将 android:button 属性设置为新的选择器 xml。这样您就可以完全控制它在目标设备上的外观。

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_checked="true" android:state_focused="true"
            android:drawable="@drawable/btn_check_on_focused_holo_light" /> 
    <item android:state_checked="false" android:state_focused="true"
            android:drawable="@drawable/btn_check_off_focused_holo_light" />
    <item android:state_checked="false"
            android:drawable="@drawable/btn_check_off_holo_light" />
    <item android:state_checked="true"
            android:drawable="@drawable/btn_check_on_holo_light" />
</selector>
Run Code Online (Sandbox Code Playgroud)