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.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken CheckedTextView, when user clicked on textview, it will show check image.
android.widget.CheckedTextView. An extension to TextView that supports the Checkable interface and displays. This is useful when used in a ListView where the setChoiceMode has been set to something other than CHOICE_MODE_NONE .
In Android, CheckedTextView is an extension of normal TextView that supports the checkable interface and displays it. It has a checkbox along with some text. It is mainly used in a ListView where we want to show which item is selected or not.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With