I am developing android application In that i use check box but default check box tick color is blue so i want to change that color to yellow. is there any inbuilt property to set color to check box tick.
If your minSdkVersion is 21+ use android:buttonTint attribute to update the color of a checkbox: <CheckBox ... android:buttonTint="@color/tint_color" /> In projects that use AppCompat library and support Android versions below 21 you can use a compat version of the buttonTint attribute:
All Checkbox widgets has same mark icon present inside them which is a right tick mark icon. In flutter the Checkbox widget has a property named as checkColor which is used to Flutter Change Checkbox Checked Icon Color in Android iOS apps. The default color property is White color.
In short: create a style for the checkbox, e.g. checkboxStyle and then implement it as a theme: android:theme="@style/checkboxStyle" Firstly, we must create a drawable that include checked and uncheck color situations, then you must set this drawable as buttonTint;
Custom checkbox is required by thousands of android developer who wish to modify the checkbox functionality according to their customer requirement . So here is the complete step by step tutorial for Material Design Custom Checkbox using theme.
Unfortunately, changing the color of checkbox check mark isn't a simple attribute
Create a selector xml file in res\drawables\
folder with name cb_selector.xml
<?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/checked" />
<item android:state_checked="false" android:drawable="@drawable/unchecked" />
</selector>
In your layout file apply this file to your checkBox
<CheckBox
android:id="@+id/cb"
android:text="My CheckBox"
android:button="@drawable/cb_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Add a unchecked.png
, and checked.png
in your drawables
folder. These are checked and unchecked image of checkbox.
You can use the attribute app:buttonTint
of the AppCompatCheckBox
from the android.support.v7 library.
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:buttonTint="@color/colorAccent"/>
Advantage: works also below API 21 and you don't need to redraw the checkbox.
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