Question

In my android code I have this

<CheckedTextView
    android:id="@+id/rememberMe"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/advancedMenu"
    android:layout_below="@+id/logInMode"
    android:checkMark="@drawable/bg_checkbox"
    android:gravity="center|center_horizontal"
    android:text="@string/rememberMe"
    android:textColor="#ffffff" />

And bg_checkbox is

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_checked="true" 
        android:drawable="@drawable/checkbox_checked"
        android:state_focused="false">
    </item>
    <item android:state_checked="true" 
        android:drawable="@drawable/checkbox_checked"
        android:state_focused="true">
    </item>
    <item android:state_checked="false" 
        android:drawable="@drawable/checkbox"
        android:state_focused="false">
    </item>
    <item android:state_checked="false" 
        android:drawable="@drawable/checkbox"
        android:state_focused="true">
    </item>
</selector>

This selector works for regular checkbox's, but for this, it's not working, its just showing the unchecked state even if I click it.

Also, how can I put some space between the text and the checkbox?

No correct solution

OTHER TIPS

Try using setCompoundDrawablePadding(int) (or android:drawablePadding in XML) to set some space between the text and checkbox.

Regarding getting the selector working, <CheckedTextView> extends TextView, so try setting android:clickable="true".

Obviously, if you're using the CheckedTextView in a ListView, make sure your ChoiceMode isn't set to CHOICE_MODE_NONE.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top