Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing the 'box' from the checkbox in Android

I am an entry level software developer, and have found tons of great answers from this site, but I can't seem to find how to hide the 'box' of a checkbox in Android. I just want the check mark to show, when a user selects an option. Here are some of the most recent things I have tried.

chkSortOrder.setBackgroundResource(android.R.color.transparent); chkSortOrder.setBackgroundResource(android.R.drawable.checkbox_off_background);

Both of these still show the box.

like image 369
Jason Avatar asked Apr 17 '13 14:04

Jason


People also ask

How do I toggle CheckBox in Android?

By default, the android CheckBox will be in the OFF (Unchecked) state. We can change the default state of CheckBox by using android:checked attribute. In case, if we want to change the state of CheckBox to ON (Checked), then we need to set android:checked = “true” in our XML layout file.

How to handle toggle button and CheckBox event in android?

To define the click event handler for a checkbox, add the android:onClick attribute to the <CheckBox> element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event. The Activity hosting the layout must then implement the corresponding method.


1 Answers

put the following attribute in your checkbox tag in XML.

android:button="@android:color/transparent"
like image 190
Joseph Avatar answered Nov 03 '22 08:11

Joseph