How to customize the color of the CheckMark color in android in a dialog. Currently , By default, the color of the checkmark is green by default. I would like to customize it to a different color of choice
views:
217answers:
2
A:
You have to override checkbox widget styles with modified drawable resources. Here is good guide to start with styles/themes http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/
Konstantin Burov
2010-08-16 07:10:30
+2
A:
If you look at the styles.xml from android system, you will see that the checkbox style is defined as follows :
<style name="Widget.CompoundButton.CheckBox">
<item name="android:background">@android:drawable/btn_check_label_background</item>
<item name="android:button">@android:drawable/btn_check</item>
</style>
And If you search the resources of the system, you will see that btn_check is a drawable selector with 2 states (on/off) with the check colored green or not.
So if you want to have your own color-drawable, here is what you should do :
- create a styles.xml
- define the 2 drawables to use
- create the xml file supporting the selector
You can find the full documentation quite detailled on the android google doc.
Sephy
2010-08-16 07:28:06
Hi, I still could not succeed in implementing the solution.
Karthik
2010-09-06 10:45:12
Can u please help me with a bit more information regarding the same. I have pasted a sample java file for the same. Please help me what exactky i need to do to to have my checkbox color to be changed to some other color instead of red.
Karthik
2010-09-06 10:46:30
AlertDialog.Builder checkbox_dialog = new AlertDialog.Builder( DialogCheckBox.this); checkbox_dialog.setTitle("Main Title goes here"); checkbox_dialog.setMultiChoiceItems(myitems, choiceitems, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int which, boolean isChecked) { Log.d("TAG","items getting selected"); } });
Karthik
2010-09-06 10:48:46
Please edit your first post with this code, this will help next users to find answers to their questions more easily and we will also have a better display with the code styling. You should add your java code, the xml file of your selector to see if there is something wrong.
Sephy
2010-09-06 21:25:21