Change checkMark or size of CheckedTextView
Asked Answered
A

1

5

I'm working on an application where I'm using a checkedTextView, it all works great. But I really don't like that layout of the "checkbox" within the checkedTextView, it's simply to big. Is there any way to resize it or change the layout to something custom made?

I've tried the android:checkMark attribute, but that resulted in it being marked all the time, and thus showing all the time.

Aplanatic answered 31/10, 2011 at 13:4 Comment(0)
S
18

Instead of using a single drawable you should write a selector:

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

And then set it to the android:checkMark attribute.

Sustentacular answered 31/10, 2011 at 13:28 Comment(4)
This didnt work for me, the check mark still doesnt change :/Outlandish
@Siavash, you most likely need to implement the onClickListener for the CheckedTextView, to run ((CheckedTextView)view).toggle();Measures
it works for me!but ,if if it was not checked ,i set checkmark null,how do i set itFinial
Works well, I just set it to android:drawableLeft with android:checkMark="@null" as I wanted to have the checkbox on the left.Bonbon

© 2022 - 2024 — McMap. All rights reserved.