How to change the color of a CheckBox?












156















How do I change the default CheckBox color in Android?

By default the CheckBox color is green, and I want to change this color.

If it is not possible please tell me how to make a custom CheckBox?










share|improve this question




















  • 1





    Are you trying to change the font's color? Or the color of the actual box?

    – user725913
    May 2 '11 at 6:28






  • 1





    actual box color i change

    – Piyush
    Jul 30 '14 at 6:46






  • 58





    Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

    – shauvik
    Jun 24 '15 at 22:53






  • 6





    @Shauvik it just working on material design :)

    – Mucahit
    Jul 13 '15 at 13:30






  • 8





    @shauvik it's better to use app:buttonTint="@color/mybrown" instead, this way it can work on API < 21

    – Nikaoto
    Aug 6 '17 at 12:52
















156















How do I change the default CheckBox color in Android?

By default the CheckBox color is green, and I want to change this color.

If it is not possible please tell me how to make a custom CheckBox?










share|improve this question




















  • 1





    Are you trying to change the font's color? Or the color of the actual box?

    – user725913
    May 2 '11 at 6:28






  • 1





    actual box color i change

    – Piyush
    Jul 30 '14 at 6:46






  • 58





    Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

    – shauvik
    Jun 24 '15 at 22:53






  • 6





    @Shauvik it just working on material design :)

    – Mucahit
    Jul 13 '15 at 13:30






  • 8





    @shauvik it's better to use app:buttonTint="@color/mybrown" instead, this way it can work on API < 21

    – Nikaoto
    Aug 6 '17 at 12:52














156












156








156


27






How do I change the default CheckBox color in Android?

By default the CheckBox color is green, and I want to change this color.

If it is not possible please tell me how to make a custom CheckBox?










share|improve this question
















How do I change the default CheckBox color in Android?

By default the CheckBox color is green, and I want to change this color.

If it is not possible please tell me how to make a custom CheckBox?







android android-checkbox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 24 '15 at 16:50









JJD

25.7k36154255




25.7k36154255










asked May 2 '11 at 6:22









PiyushPiyush

2,44842225




2,44842225








  • 1





    Are you trying to change the font's color? Or the color of the actual box?

    – user725913
    May 2 '11 at 6:28






  • 1





    actual box color i change

    – Piyush
    Jul 30 '14 at 6:46






  • 58





    Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

    – shauvik
    Jun 24 '15 at 22:53






  • 6





    @Shauvik it just working on material design :)

    – Mucahit
    Jul 13 '15 at 13:30






  • 8





    @shauvik it's better to use app:buttonTint="@color/mybrown" instead, this way it can work on API < 21

    – Nikaoto
    Aug 6 '17 at 12:52














  • 1





    Are you trying to change the font's color? Or the color of the actual box?

    – user725913
    May 2 '11 at 6:28






  • 1





    actual box color i change

    – Piyush
    Jul 30 '14 at 6:46






  • 58





    Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

    – shauvik
    Jun 24 '15 at 22:53






  • 6





    @Shauvik it just working on material design :)

    – Mucahit
    Jul 13 '15 at 13:30






  • 8





    @shauvik it's better to use app:buttonTint="@color/mybrown" instead, this way it can work on API < 21

    – Nikaoto
    Aug 6 '17 at 12:52








1




1





Are you trying to change the font's color? Or the color of the actual box?

– user725913
May 2 '11 at 6:28





Are you trying to change the font's color? Or the color of the actual box?

– user725913
May 2 '11 at 6:28




1




1





actual box color i change

– Piyush
Jul 30 '14 at 6:46





actual box color i change

– Piyush
Jul 30 '14 at 6:46




58




58





Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

– shauvik
Jun 24 '15 at 22:53





Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

– shauvik
Jun 24 '15 at 22:53




6




6





@Shauvik it just working on material design :)

– Mucahit
Jul 13 '15 at 13:30





@Shauvik it just working on material design :)

– Mucahit
Jul 13 '15 at 13:30




8




8





@shauvik it's better to use app:buttonTint="@color/mybrown" instead, this way it can work on API < 21

– Nikaoto
Aug 6 '17 at 12:52





@shauvik it's better to use app:buttonTint="@color/mybrown" instead, this way it can work on API < 21

– Nikaoto
Aug 6 '17 at 12:52












19 Answers
19






active

oldest

votes


















46














You can change CheckBoxs drawable using android:button="@drawable/your_check_drawable" attribute.






share|improve this answer



















  • 7





    You'd have to create your own drawable. There's gotta be a more straight-forward way...

    – IgorGanapolsky
    Sep 14 '16 at 16:07






  • 26





    bad approach...

    – Trung Le
    Mar 14 '17 at 4:38






  • 13





    Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

    – Neela
    Aug 6 '17 at 13:14






  • 3





    Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

    – SimpsOff
    Aug 9 '18 at 14:15



















360














You can change the color directly in XML. Use buttonTint for the box: (as of API level 23)



<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/CHECK_COLOR" />


You can also do this using appCompatCheckbox v7 for older API levels:



<android.support.v7.widget.AppCompatCheckBox 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:buttonTint="@color/COLOR_HERE" />





share|improve this answer





















  • 4





    AppCompatCheckBox... Thanks. I didn't know this.

    – moskis
    Feb 10 '16 at 15:24






  • 7





    Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

    – Alberto Méndez
    Mar 15 '16 at 11:45








  • 2





    Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

    – Zvi
    Jun 13 '16 at 18:12






  • 1





    This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

    – bong jae choe
    Apr 12 '17 at 9:22






  • 1





    How about setting 2 different colors for checked and unchecked states?

    – DYS
    Nov 29 '17 at 7:10



















106














you can set android theme of the checkbox to get the color you want in your styles.xml add :



<style name="checkBoxStyle" parent="Base.Theme.AppCompat">
<item name="colorAccent">CHECKEDHIGHLIGHTCOLOR</item>
<item name="android:textColorSecondary">UNCHECKEDCOLOR</item>
</style>


then in your layout file :



<CheckBox
android:theme="@style/checkBoxStyle"
android:id="@+id/chooseItemCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>


unlike using android:buttonTint="@color/CHECK_COLOR" this method works under Api 23






share|improve this answer



















  • 2





    TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

    – Mulgard
    May 27 '16 at 7:53











  • @Mulgard glad I can help !

    – Amro elaswar
    May 27 '16 at 17:45






  • 1





    Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

    – Zvi
    Jun 13 '16 at 18:32











  • How do I do it also programmatically?

    – Zvi
    Jul 16 '16 at 17:29











  • @Zvi I am not sure you can do this programatically

    – Amro elaswar
    Jul 16 '16 at 17:43



















36














Programmatic version:



int states = {{android.R.attr.state_checked}, {}};
int colors = {color_for_state_checked, color_for_state_normal}
CompoundButtonCompat.setButtonTintList(checkbox, new ColorStateList(states, colors));





share|improve this answer



















  • 1





    Thanks to You. You rocks, The better solution.

    – Carlos
    Aug 25 '17 at 1:18











  • it gave me unexpected result with colors, are you sure you didn't confuse anything?

    – Kirill Karmazin
    Oct 22 '18 at 11:50











  • @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

    – kyay
    Feb 8 at 22:38











  • @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

    – nyholku
    Feb 9 at 8:41











  • But still, if it can be done in xml, it should be

    – kyay
    Feb 9 at 15:16



















23














Use buttonTint and color selector



<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:buttonTint="@color/checkbox_filter_tint"/>


res/colors/checkbox_filter_tint.xml



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





share|improve this answer





















  • 3





    Can you speak English and explain your answer plse

    – GGO
    Sep 27 '17 at 13:37











  • Always stick with English in SO.

    – nyconing
    Dec 27 '17 at 3:23











  • It is a better answer

    – Vivek A Naik
    Nov 23 '18 at 11:40



















15














<CheckBox
android:id="@+id/chk_remember_signup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@android:color/white"
android:text="@string/hint_chk_remember_me" />





share|improve this answer



















  • 1





    The content of this answer already exists in afathman's answer.

    – MTCoster
    Jul 29 '16 at 12:52



















11














Add this line in your styles.xml file:



<style>
<item name="android:colorAccent">@android:color/holo_green_dark</item>
</style>





share|improve this answer


























  • Please edit your answer with your example and don't post it as a comment

    – bish
    Jul 11 '15 at 7:24






  • 4





    Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

    – user3829751
    Oct 6 '15 at 19:16













  • this changes the colorAccent, it's not what it was asked

    – Alberto M
    Jul 27 '16 at 13:24











  • On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

    – Slava
    May 15 '17 at 17:53



















11














I would suggest to use he style approach in android as the way to configure built-in android views, add new style in your project:



<style name="yourStyle" parent="Base.Theme.AppCompat">
<item name="colorAccent">your_color</item> <!-- for uncheck state -->
<item name="android:textColorSecondary">your color</item> <!-- for check state -->
</style>


and add assign this style to the theme of the checkbox:
android:theme="@style/youStyle"



hope this helps.






share|improve this answer
























  • agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

    – Trung Le
    Mar 14 '17 at 4:38






  • 1





    This is a repeat of Amro elaswar's answer from 9 months earlier.

    – jk7
    Feb 9 '18 at 19:32











  • This is the kind of solution that is A REAL SOLUTION.

    – Iharob Al Asimi
    Jun 20 '18 at 17:42











  • It works for below 21 also. Thanks

    – niketshah09
    Oct 4 '18 at 9:02





















6














Me faced same problem, I got a solution using below technic. Copy the btn_check.xml from android-sdk/platforms/android-#(version)/data/res/drawable to your project's drawable folder and change the 'on' and 'off' image states to your custom images.

Then your xml will just need android:button="@drawable/btn_check"



<CheckBox
android:button="@drawable/btn_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />


If you want to use different default Android icons, you can use:



android:button="@android:drawable/..."





share|improve this answer


























  • Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

    – Gene Bo
    Apr 23 '15 at 16:24






  • 1





    There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

    – Gene Bo
    Apr 23 '15 at 18:27



















6














buttonTint worked for me try



android:buttonTint="@color/white"



<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/agreeCheckBox"
android:text="@string/i_agree_to_terms_s"
android:buttonTint="@color/white"
android:layout_below="@+id/avoid_spam_text"/>





share|improve this answer































    3














    You can change checkbox color using singe line of code



    android:buttonTint="@color/app_color" //whatever color






    share|improve this answer

































      2














      you can create your own xml in drawable and use this as android:background="@drawable/your_xml"



      in that you can give border corner everything






      <item>
      <shape>
      <gradient

      android:endColor="#fff"
      android:startColor="#fff"/>
      <corners
      android:radius="2dp"/>
      <stroke
      android:width="15dp"
      android:color="#0013669e"/>

      </shape>
      </item>







      share|improve this answer



















      • 1





        Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

        – Mike Poole
        Jan 10 '18 at 7:24



















      2














      Hi This is the theme code for both Dark Theme and Light Theme.



      <attr name="buttonsearch_picture" format="reference"/>
      <attr name="buttonrefresh_picture" format="reference"/>

      <style name="Theme.Light" parent="Theme.AppCompat.Light.NoActionBar">
      <item name="android:windowNoTitle">true</item>
      <item name="android:windowBackground">@color/white</item>
      <item name="android:windowActionBar">false</item>
      <item name="android:textColorPrimary">@color/black</item>
      <item name="android:textColorSecondary">@color/black</item>
      <item name="android:textColor">@color/material_gray_800</item>
      <item name="actionOverflowButtonStyle">@style/LightOverflowButtonStyle</item>
      <item name="buttonsearch_picture">@drawable/ic_search_black</item>
      <item name="buttonrefresh_picture">@drawable/ic_refresh_black</item>
      </style>

      <style name="Theme.Dark" parent="Theme.AppCompat.NoActionBar">
      <item name="android:windowNoTitle">true</item>
      <item name="android:windowBackground">@color/white</item>
      <item name="android:windowActionBar">false</item>
      <item name="android:textColorPrimary">@color/white</item>
      <item name="android:textColorSecondary">@color/material_gray_500</item>
      <item name="android:textColor">@color/material_gray_800</item>
      <item name="actionOverflowButtonStyle">@style/DarkOverflowButtonStyle</item>
      <item name="buttonsearch_picture">@drawable/ic_search_white</item>
      <item name="buttonrefresh_picture">@drawable/ic_refresh_white</item>
      <item name="android:colorBackground">#ffffff</item>
      <item name="android:alertDialogTheme">@style/LightDialogTheme</item>
      <item name="android:alertDialogStyle">@style/LightDialogTheme</item>
      <!-- <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>-->
      <item name="android:popupMenuStyle">@style/PopupMenu</item>
      </style>


      If you want to change checkbox color then "colorAccent" attribute will use for checked state and "android:textColorSecondary" will use for unchecking state.



      "actionOverflowButtonStyle" will use for change the color of overflow icon in the Action bar.



      "buttonsearch_picture" attribute will use for change tint color of Action Button in Action Bar.This is custom Attribute in style.xml



      <attr name="buttonsearch_picture" format="reference"/>


      Same is for refresh button which i am using in my app.



      "android:popupMenuStyle" attribute is using to get Light theme popup menu style in Dark theme.



      <style name="PopupMenu" parent="Theme.AppCompat.Light.NoActionBar">
      </style>


      And this is toolbar Code which I am using in my Rocks Player App.



       <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      app:contentInsetStart="0dp"
      android:title="Rocks Player"
      android:layout_width="match_parent"
      android:elevation="4dp"
      android:layout_height="48dp"
      app:layout_scrollFlags="scroll|enterAlways"
      android:minHeight="48dp"
      app:titleTextAppearance="@style/Toolbar.TitleText"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      android:background="?attr/colorPrimary"
      >
      </android.support.v7.widget.Toolbar>


      Themes:-



       <style name="AppTheme0" parent="Theme.Light">
      <item name="colorPrimary">#ffffff</item>
      <item name="colorPrimaryDark">#cccccc</item>
      <item name="colorAccent">#0294ff</item>
      </style>

      <style name="AppTheme1" parent="Theme.Dark">
      <item name="colorPrimary">#4161b2</item>
      <item name="colorPrimaryDark">#4161b2</item>
      <item name="colorAccent">#4161b2</item>
      </style>





      share|improve this answer































        1














        create an xml Drawable resource file under res->drawable and name it, for example, checkbox_custom_01.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/checkbox_custom_01_checked_white_green_32" />
        <item
        android:state_checked="false"
        android:drawable="@drawable/checkbox_custom_01_unchecked_gray_32" />
        </selector>


        Upload your custom checkbox image files (i recommend png) to your res->drawable folder.



        Then go in your layout file and change your checkbox to



        <CheckBox
        android:id="@+id/checkBox1"
        android:button="@drawable/checkbox_custom_01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="CheckBox"
        android:textSize="32dip"/>


        you may customize anything, as long as android:button points to the correct XML file you created before.



        NOTE TO NEWBIES: though it is not mandatory, it is nevertheless good practice to name your checkbox with a unique id throughout your whole layout tree.






        share|improve this answer































          0














          You can change the background color of the <CheckBox> by embedding it inside a <LinearLayout>. Then change the background color of <LinearLayout> to the color you want.






          share|improve this answer


























          • The question is about the color of the checkbox and not the background

            – Zvi
            Jul 16 '16 at 17:30



















          0














          You should try below code. It is working for me.



          <selector xmlns:android="http://schemas.android.com/apk/res/android">
          <item android:drawable="@drawable/checked"
          android:state_checked="true">
          <color android:color="@color/yello" />
          </item>
          <!-- checked -->
          <item android:drawable="@drawable/unchecked"
          android:state_checked="false">
          <color android:color="@color/black"></color>
          </item>
          <!-- unchecked -->
          <item android:drawable="@drawable/checked"
          android:state_focused="true">
          <color android:color="@color/yello"></color>
          </item>
          <!-- on focus -->
          <item android:drawable="@drawable/unchecked">
          <color android:color="@color/black"></color>
          </item>
          <!-- default -->
          </selector>


          and CheckBox



          <CheckBox
          Button="@style/currentcy_check_box_style"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingLeft="20dp"
          android:text="@string/step_one_currency_aud" />





          share|improve this answer

































            0














            If you are going to use the android icons, as described above ..



            android:button="@android:drawable/..."


            .. it's a nice option, but for this to work - I found you need to add toggle logic to show/hide the check mark, like this:



                checkBoxShowPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            // checkbox status is changed from uncheck to checked.
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            int btnDrawable = android.R.drawable.checkbox_off_background;

            if (isChecked)
            {
            btnDrawable = android.R.drawable.checkbox_on_background;
            }

            checkBoxShowPwd.setButtonDrawable(btnDrawable);

            }
            });





            share|improve this answer
























            • Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

              – jkincali
              Feb 22 '17 at 16:09



















            0














            You can use the following two properties in "colors.xml"



            <color name="colorControlNormal">#eeeeee</color>
            <color name="colorControlActivated">#eeeeee</color>


            colorControlNormal is for the normal view of checkbox, and colorControlActivated is for when the checkbox is checked.






            share|improve this answer































              0














              100% robust approach.



              In my case, I didn't have access to the XML layout source file, since I get Checkbox from a 3-rd party MaterialDialog lib.
              So I have to solve this programmatically.




              1. Create a ColorStateList in xml:


              res/color/checkbox_tinit_dark_theme.xml:



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




              1. Then apply it to the checkbox:



                ColorStateList darkStateList = ContextCompat.getColorStateList(getContext(), R.color.checkbox_tint_dark_theme);
                CompoundButtonCompat.setButtonTintList(checkbox, darkStateList);



              P.S. In addition if someone is interested, here is how you can get your checkbox from MaterialDialog dialog (if you set it with .checkBoxPromptRes(...)):



              CheckBox checkbox = (CheckBox) dialog.getView().findViewById(R.id.md_promptCheckbox);


              Hope this helps.






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5854047%2fhow-to-change-the-color-of-a-checkbox%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                19 Answers
                19






                active

                oldest

                votes








                19 Answers
                19






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                46














                You can change CheckBoxs drawable using android:button="@drawable/your_check_drawable" attribute.






                share|improve this answer



















                • 7





                  You'd have to create your own drawable. There's gotta be a more straight-forward way...

                  – IgorGanapolsky
                  Sep 14 '16 at 16:07






                • 26





                  bad approach...

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 13





                  Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

                  – Neela
                  Aug 6 '17 at 13:14






                • 3





                  Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

                  – SimpsOff
                  Aug 9 '18 at 14:15
















                46














                You can change CheckBoxs drawable using android:button="@drawable/your_check_drawable" attribute.






                share|improve this answer



















                • 7





                  You'd have to create your own drawable. There's gotta be a more straight-forward way...

                  – IgorGanapolsky
                  Sep 14 '16 at 16:07






                • 26





                  bad approach...

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 13





                  Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

                  – Neela
                  Aug 6 '17 at 13:14






                • 3





                  Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

                  – SimpsOff
                  Aug 9 '18 at 14:15














                46












                46








                46







                You can change CheckBoxs drawable using android:button="@drawable/your_check_drawable" attribute.






                share|improve this answer













                You can change CheckBoxs drawable using android:button="@drawable/your_check_drawable" attribute.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 2 '11 at 6:33









                MichaelMichael

                41.2k16107128




                41.2k16107128








                • 7





                  You'd have to create your own drawable. There's gotta be a more straight-forward way...

                  – IgorGanapolsky
                  Sep 14 '16 at 16:07






                • 26





                  bad approach...

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 13





                  Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

                  – Neela
                  Aug 6 '17 at 13:14






                • 3





                  Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

                  – SimpsOff
                  Aug 9 '18 at 14:15














                • 7





                  You'd have to create your own drawable. There's gotta be a more straight-forward way...

                  – IgorGanapolsky
                  Sep 14 '16 at 16:07






                • 26





                  bad approach...

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 13





                  Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

                  – Neela
                  Aug 6 '17 at 13:14






                • 3





                  Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

                  – SimpsOff
                  Aug 9 '18 at 14:15








                7




                7





                You'd have to create your own drawable. There's gotta be a more straight-forward way...

                – IgorGanapolsky
                Sep 14 '16 at 16:07





                You'd have to create your own drawable. There's gotta be a more straight-forward way...

                – IgorGanapolsky
                Sep 14 '16 at 16:07




                26




                26





                bad approach...

                – Trung Le
                Mar 14 '17 at 4:38





                bad approach...

                – Trung Le
                Mar 14 '17 at 4:38




                13




                13





                Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

                – Neela
                Aug 6 '17 at 13:14





                Changing buttonTint colour is a more straight forward way. We have to use the native elements instead customising it unnecessarily.

                – Neela
                Aug 6 '17 at 13:14




                3




                3





                Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

                – SimpsOff
                Aug 9 '18 at 14:15





                Note: For material design styling, there is the contentControl options now: materialdoc.com/components/selection-controls

                – SimpsOff
                Aug 9 '18 at 14:15













                360














                You can change the color directly in XML. Use buttonTint for the box: (as of API level 23)



                <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@color/CHECK_COLOR" />


                You can also do this using appCompatCheckbox v7 for older API levels:



                <android.support.v7.widget.AppCompatCheckBox 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/COLOR_HERE" />





                share|improve this answer





















                • 4





                  AppCompatCheckBox... Thanks. I didn't know this.

                  – moskis
                  Feb 10 '16 at 15:24






                • 7





                  Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

                  – Alberto Méndez
                  Mar 15 '16 at 11:45








                • 2





                  Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

                  – Zvi
                  Jun 13 '16 at 18:12






                • 1





                  This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

                  – bong jae choe
                  Apr 12 '17 at 9:22






                • 1





                  How about setting 2 different colors for checked and unchecked states?

                  – DYS
                  Nov 29 '17 at 7:10
















                360














                You can change the color directly in XML. Use buttonTint for the box: (as of API level 23)



                <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@color/CHECK_COLOR" />


                You can also do this using appCompatCheckbox v7 for older API levels:



                <android.support.v7.widget.AppCompatCheckBox 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/COLOR_HERE" />





                share|improve this answer





















                • 4





                  AppCompatCheckBox... Thanks. I didn't know this.

                  – moskis
                  Feb 10 '16 at 15:24






                • 7





                  Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

                  – Alberto Méndez
                  Mar 15 '16 at 11:45








                • 2





                  Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

                  – Zvi
                  Jun 13 '16 at 18:12






                • 1





                  This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

                  – bong jae choe
                  Apr 12 '17 at 9:22






                • 1





                  How about setting 2 different colors for checked and unchecked states?

                  – DYS
                  Nov 29 '17 at 7:10














                360












                360








                360







                You can change the color directly in XML. Use buttonTint for the box: (as of API level 23)



                <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@color/CHECK_COLOR" />


                You can also do this using appCompatCheckbox v7 for older API levels:



                <android.support.v7.widget.AppCompatCheckBox 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/COLOR_HERE" />





                share|improve this answer















                You can change the color directly in XML. Use buttonTint for the box: (as of API level 23)



                <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@color/CHECK_COLOR" />


                You can also do this using appCompatCheckbox v7 for older API levels:



                <android.support.v7.widget.AppCompatCheckBox 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/COLOR_HERE" />






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 10 at 7:12









                Ishaan Javali

                1,3543821




                1,3543821










                answered Nov 20 '15 at 19:21









                afathmanafathman

                4,94421625




                4,94421625








                • 4





                  AppCompatCheckBox... Thanks. I didn't know this.

                  – moskis
                  Feb 10 '16 at 15:24






                • 7





                  Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

                  – Alberto Méndez
                  Mar 15 '16 at 11:45








                • 2





                  Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

                  – Zvi
                  Jun 13 '16 at 18:12






                • 1





                  This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

                  – bong jae choe
                  Apr 12 '17 at 9:22






                • 1





                  How about setting 2 different colors for checked and unchecked states?

                  – DYS
                  Nov 29 '17 at 7:10














                • 4





                  AppCompatCheckBox... Thanks. I didn't know this.

                  – moskis
                  Feb 10 '16 at 15:24






                • 7





                  Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

                  – Alberto Méndez
                  Mar 15 '16 at 11:45








                • 2





                  Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

                  – Zvi
                  Jun 13 '16 at 18:12






                • 1





                  This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

                  – bong jae choe
                  Apr 12 '17 at 9:22






                • 1





                  How about setting 2 different colors for checked and unchecked states?

                  – DYS
                  Nov 29 '17 at 7:10








                4




                4





                AppCompatCheckBox... Thanks. I didn't know this.

                – moskis
                Feb 10 '16 at 15:24





                AppCompatCheckBox... Thanks. I didn't know this.

                – moskis
                Feb 10 '16 at 15:24




                7




                7





                Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

                – Alberto Méndez
                Mar 15 '16 at 11:45







                Nice, thanks! And don't forget to add xmlns:app="schemas.android.com/apk/res-auto" to your main/parent layout

                – Alberto Méndez
                Mar 15 '16 at 11:45






                2




                2





                Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

                – Zvi
                Jun 13 '16 at 18:12





                Not working for me using 'android.support.v7.widget.AppCompatCheckBox'

                – Zvi
                Jun 13 '16 at 18:12




                1




                1





                This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

                – bong jae choe
                Apr 12 '17 at 9:22





                This will automatically be used when you use CheckBox in your layouts. You should only need to manually use this class when writing custom views.

                – bong jae choe
                Apr 12 '17 at 9:22




                1




                1





                How about setting 2 different colors for checked and unchecked states?

                – DYS
                Nov 29 '17 at 7:10





                How about setting 2 different colors for checked and unchecked states?

                – DYS
                Nov 29 '17 at 7:10











                106














                you can set android theme of the checkbox to get the color you want in your styles.xml add :



                <style name="checkBoxStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">CHECKEDHIGHLIGHTCOLOR</item>
                <item name="android:textColorSecondary">UNCHECKEDCOLOR</item>
                </style>


                then in your layout file :



                <CheckBox
                android:theme="@style/checkBoxStyle"
                android:id="@+id/chooseItemCheckBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>


                unlike using android:buttonTint="@color/CHECK_COLOR" this method works under Api 23






                share|improve this answer



















                • 2





                  TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

                  – Mulgard
                  May 27 '16 at 7:53











                • @Mulgard glad I can help !

                  – Amro elaswar
                  May 27 '16 at 17:45






                • 1





                  Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

                  – Zvi
                  Jun 13 '16 at 18:32











                • How do I do it also programmatically?

                  – Zvi
                  Jul 16 '16 at 17:29











                • @Zvi I am not sure you can do this programatically

                  – Amro elaswar
                  Jul 16 '16 at 17:43
















                106














                you can set android theme of the checkbox to get the color you want in your styles.xml add :



                <style name="checkBoxStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">CHECKEDHIGHLIGHTCOLOR</item>
                <item name="android:textColorSecondary">UNCHECKEDCOLOR</item>
                </style>


                then in your layout file :



                <CheckBox
                android:theme="@style/checkBoxStyle"
                android:id="@+id/chooseItemCheckBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>


                unlike using android:buttonTint="@color/CHECK_COLOR" this method works under Api 23






                share|improve this answer



















                • 2





                  TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

                  – Mulgard
                  May 27 '16 at 7:53











                • @Mulgard glad I can help !

                  – Amro elaswar
                  May 27 '16 at 17:45






                • 1





                  Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

                  – Zvi
                  Jun 13 '16 at 18:32











                • How do I do it also programmatically?

                  – Zvi
                  Jul 16 '16 at 17:29











                • @Zvi I am not sure you can do this programatically

                  – Amro elaswar
                  Jul 16 '16 at 17:43














                106












                106








                106







                you can set android theme of the checkbox to get the color you want in your styles.xml add :



                <style name="checkBoxStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">CHECKEDHIGHLIGHTCOLOR</item>
                <item name="android:textColorSecondary">UNCHECKEDCOLOR</item>
                </style>


                then in your layout file :



                <CheckBox
                android:theme="@style/checkBoxStyle"
                android:id="@+id/chooseItemCheckBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>


                unlike using android:buttonTint="@color/CHECK_COLOR" this method works under Api 23






                share|improve this answer













                you can set android theme of the checkbox to get the color you want in your styles.xml add :



                <style name="checkBoxStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">CHECKEDHIGHLIGHTCOLOR</item>
                <item name="android:textColorSecondary">UNCHECKEDCOLOR</item>
                </style>


                then in your layout file :



                <CheckBox
                android:theme="@style/checkBoxStyle"
                android:id="@+id/chooseItemCheckBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>


                unlike using android:buttonTint="@color/CHECK_COLOR" this method works under Api 23







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 14 '16 at 23:44









                Amro elaswarAmro elaswar

                1,94721430




                1,94721430








                • 2





                  TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

                  – Mulgard
                  May 27 '16 at 7:53











                • @Mulgard glad I can help !

                  – Amro elaswar
                  May 27 '16 at 17:45






                • 1





                  Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

                  – Zvi
                  Jun 13 '16 at 18:32











                • How do I do it also programmatically?

                  – Zvi
                  Jul 16 '16 at 17:29











                • @Zvi I am not sure you can do this programatically

                  – Amro elaswar
                  Jul 16 '16 at 17:43














                • 2





                  TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

                  – Mulgard
                  May 27 '16 at 7:53











                • @Mulgard glad I can help !

                  – Amro elaswar
                  May 27 '16 at 17:45






                • 1





                  Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

                  – Zvi
                  Jun 13 '16 at 18:32











                • How do I do it also programmatically?

                  – Zvi
                  Jul 16 '16 at 17:29











                • @Zvi I am not sure you can do this programatically

                  – Amro elaswar
                  Jul 16 '16 at 17:43








                2




                2





                TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

                – Mulgard
                May 27 '16 at 7:53





                TEXTCOLORSECONDARY!!!! THank you man! That's it. I searched for ages to just change the unselected background color and did not want to work with custom drawables. This is it!

                – Mulgard
                May 27 '16 at 7:53













                @Mulgard glad I can help !

                – Amro elaswar
                May 27 '16 at 17:45





                @Mulgard glad I can help !

                – Amro elaswar
                May 27 '16 at 17:45




                1




                1





                Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

                – Zvi
                Jun 13 '16 at 18:32





                Worked for me, but needed to add to the CheckBox xml to be able to see the text - android:textColor="@color/textColor"

                – Zvi
                Jun 13 '16 at 18:32













                How do I do it also programmatically?

                – Zvi
                Jul 16 '16 at 17:29





                How do I do it also programmatically?

                – Zvi
                Jul 16 '16 at 17:29













                @Zvi I am not sure you can do this programatically

                – Amro elaswar
                Jul 16 '16 at 17:43





                @Zvi I am not sure you can do this programatically

                – Amro elaswar
                Jul 16 '16 at 17:43











                36














                Programmatic version:



                int states = {{android.R.attr.state_checked}, {}};
                int colors = {color_for_state_checked, color_for_state_normal}
                CompoundButtonCompat.setButtonTintList(checkbox, new ColorStateList(states, colors));





                share|improve this answer



















                • 1





                  Thanks to You. You rocks, The better solution.

                  – Carlos
                  Aug 25 '17 at 1:18











                • it gave me unexpected result with colors, are you sure you didn't confuse anything?

                  – Kirill Karmazin
                  Oct 22 '18 at 11:50











                • @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

                  – kyay
                  Feb 8 at 22:38











                • @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

                  – nyholku
                  Feb 9 at 8:41











                • But still, if it can be done in xml, it should be

                  – kyay
                  Feb 9 at 15:16
















                36














                Programmatic version:



                int states = {{android.R.attr.state_checked}, {}};
                int colors = {color_for_state_checked, color_for_state_normal}
                CompoundButtonCompat.setButtonTintList(checkbox, new ColorStateList(states, colors));





                share|improve this answer



















                • 1





                  Thanks to You. You rocks, The better solution.

                  – Carlos
                  Aug 25 '17 at 1:18











                • it gave me unexpected result with colors, are you sure you didn't confuse anything?

                  – Kirill Karmazin
                  Oct 22 '18 at 11:50











                • @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

                  – kyay
                  Feb 8 at 22:38











                • @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

                  – nyholku
                  Feb 9 at 8:41











                • But still, if it can be done in xml, it should be

                  – kyay
                  Feb 9 at 15:16














                36












                36








                36







                Programmatic version:



                int states = {{android.R.attr.state_checked}, {}};
                int colors = {color_for_state_checked, color_for_state_normal}
                CompoundButtonCompat.setButtonTintList(checkbox, new ColorStateList(states, colors));





                share|improve this answer













                Programmatic version:



                int states = {{android.R.attr.state_checked}, {}};
                int colors = {color_for_state_checked, color_for_state_normal}
                CompoundButtonCompat.setButtonTintList(checkbox, new ColorStateList(states, colors));






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 7 '16 at 17:18









                mbonninmbonnin

                3,10422143




                3,10422143








                • 1





                  Thanks to You. You rocks, The better solution.

                  – Carlos
                  Aug 25 '17 at 1:18











                • it gave me unexpected result with colors, are you sure you didn't confuse anything?

                  – Kirill Karmazin
                  Oct 22 '18 at 11:50











                • @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

                  – kyay
                  Feb 8 at 22:38











                • @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

                  – nyholku
                  Feb 9 at 8:41











                • But still, if it can be done in xml, it should be

                  – kyay
                  Feb 9 at 15:16














                • 1





                  Thanks to You. You rocks, The better solution.

                  – Carlos
                  Aug 25 '17 at 1:18











                • it gave me unexpected result with colors, are you sure you didn't confuse anything?

                  – Kirill Karmazin
                  Oct 22 '18 at 11:50











                • @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

                  – kyay
                  Feb 8 at 22:38











                • @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

                  – nyholku
                  Feb 9 at 8:41











                • But still, if it can be done in xml, it should be

                  – kyay
                  Feb 9 at 15:16








                1




                1





                Thanks to You. You rocks, The better solution.

                – Carlos
                Aug 25 '17 at 1:18





                Thanks to You. You rocks, The better solution.

                – Carlos
                Aug 25 '17 at 1:18













                it gave me unexpected result with colors, are you sure you didn't confuse anything?

                – Kirill Karmazin
                Oct 22 '18 at 11:50





                it gave me unexpected result with colors, are you sure you didn't confuse anything?

                – Kirill Karmazin
                Oct 22 '18 at 11:50













                @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

                – kyay
                Feb 8 at 22:38





                @Carlos This is not a "better" solution, because in android you should always try to set all the layout stuff in the xml file and not programmatically except when you need to change it dynamically

                – kyay
                Feb 8 at 22:38













                @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

                – nyholku
                Feb 9 at 8:41





                @kyay Not "always" ... the Android resource system is a mess and often doing it programmatically is far easier and more maintainable.

                – nyholku
                Feb 9 at 8:41













                But still, if it can be done in xml, it should be

                – kyay
                Feb 9 at 15:16





                But still, if it can be done in xml, it should be

                – kyay
                Feb 9 at 15:16











                23














                Use buttonTint and color selector



                <android.support.v7.widget.AppCompatCheckBox
                android:id="@+id/check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/checkbox_filter_tint"/>


                res/colors/checkbox_filter_tint.xml



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





                share|improve this answer





















                • 3





                  Can you speak English and explain your answer plse

                  – GGO
                  Sep 27 '17 at 13:37











                • Always stick with English in SO.

                  – nyconing
                  Dec 27 '17 at 3:23











                • It is a better answer

                  – Vivek A Naik
                  Nov 23 '18 at 11:40
















                23














                Use buttonTint and color selector



                <android.support.v7.widget.AppCompatCheckBox
                android:id="@+id/check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/checkbox_filter_tint"/>


                res/colors/checkbox_filter_tint.xml



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





                share|improve this answer





















                • 3





                  Can you speak English and explain your answer plse

                  – GGO
                  Sep 27 '17 at 13:37











                • Always stick with English in SO.

                  – nyconing
                  Dec 27 '17 at 3:23











                • It is a better answer

                  – Vivek A Naik
                  Nov 23 '18 at 11:40














                23












                23








                23







                Use buttonTint and color selector



                <android.support.v7.widget.AppCompatCheckBox
                android:id="@+id/check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/checkbox_filter_tint"/>


                res/colors/checkbox_filter_tint.xml



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





                share|improve this answer















                Use buttonTint and color selector



                <android.support.v7.widget.AppCompatCheckBox
                android:id="@+id/check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:buttonTint="@color/checkbox_filter_tint"/>


                res/colors/checkbox_filter_tint.xml



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






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 20 '18 at 10:25









                Yuliia Ashomok

                4,05913748




                4,05913748










                answered Sep 27 '17 at 13:17









                D. SergeevD. Sergeev

                286212




                286212








                • 3





                  Can you speak English and explain your answer plse

                  – GGO
                  Sep 27 '17 at 13:37











                • Always stick with English in SO.

                  – nyconing
                  Dec 27 '17 at 3:23











                • It is a better answer

                  – Vivek A Naik
                  Nov 23 '18 at 11:40














                • 3





                  Can you speak English and explain your answer plse

                  – GGO
                  Sep 27 '17 at 13:37











                • Always stick with English in SO.

                  – nyconing
                  Dec 27 '17 at 3:23











                • It is a better answer

                  – Vivek A Naik
                  Nov 23 '18 at 11:40








                3




                3





                Can you speak English and explain your answer plse

                – GGO
                Sep 27 '17 at 13:37





                Can you speak English and explain your answer plse

                – GGO
                Sep 27 '17 at 13:37













                Always stick with English in SO.

                – nyconing
                Dec 27 '17 at 3:23





                Always stick with English in SO.

                – nyconing
                Dec 27 '17 at 3:23













                It is a better answer

                – Vivek A Naik
                Nov 23 '18 at 11:40





                It is a better answer

                – Vivek A Naik
                Nov 23 '18 at 11:40











                15














                <CheckBox
                android:id="@+id/chk_remember_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@android:color/white"
                android:text="@string/hint_chk_remember_me" />





                share|improve this answer



















                • 1





                  The content of this answer already exists in afathman's answer.

                  – MTCoster
                  Jul 29 '16 at 12:52
















                15














                <CheckBox
                android:id="@+id/chk_remember_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@android:color/white"
                android:text="@string/hint_chk_remember_me" />





                share|improve this answer



















                • 1





                  The content of this answer already exists in afathman's answer.

                  – MTCoster
                  Jul 29 '16 at 12:52














                15












                15








                15







                <CheckBox
                android:id="@+id/chk_remember_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@android:color/white"
                android:text="@string/hint_chk_remember_me" />





                share|improve this answer













                <CheckBox
                android:id="@+id/chk_remember_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:buttonTint="@android:color/white"
                android:text="@string/hint_chk_remember_me" />






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 29 '16 at 12:27









                Shweta ChauhanShweta Chauhan

                2,37611729




                2,37611729








                • 1





                  The content of this answer already exists in afathman's answer.

                  – MTCoster
                  Jul 29 '16 at 12:52














                • 1





                  The content of this answer already exists in afathman's answer.

                  – MTCoster
                  Jul 29 '16 at 12:52








                1




                1





                The content of this answer already exists in afathman's answer.

                – MTCoster
                Jul 29 '16 at 12:52





                The content of this answer already exists in afathman's answer.

                – MTCoster
                Jul 29 '16 at 12:52











                11














                Add this line in your styles.xml file:



                <style>
                <item name="android:colorAccent">@android:color/holo_green_dark</item>
                </style>





                share|improve this answer


























                • Please edit your answer with your example and don't post it as a comment

                  – bish
                  Jul 11 '15 at 7:24






                • 4





                  Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

                  – user3829751
                  Oct 6 '15 at 19:16













                • this changes the colorAccent, it's not what it was asked

                  – Alberto M
                  Jul 27 '16 at 13:24











                • On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

                  – Slava
                  May 15 '17 at 17:53
















                11














                Add this line in your styles.xml file:



                <style>
                <item name="android:colorAccent">@android:color/holo_green_dark</item>
                </style>





                share|improve this answer


























                • Please edit your answer with your example and don't post it as a comment

                  – bish
                  Jul 11 '15 at 7:24






                • 4





                  Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

                  – user3829751
                  Oct 6 '15 at 19:16













                • this changes the colorAccent, it's not what it was asked

                  – Alberto M
                  Jul 27 '16 at 13:24











                • On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

                  – Slava
                  May 15 '17 at 17:53














                11












                11








                11







                Add this line in your styles.xml file:



                <style>
                <item name="android:colorAccent">@android:color/holo_green_dark</item>
                </style>





                share|improve this answer















                Add this line in your styles.xml file:



                <style>
                <item name="android:colorAccent">@android:color/holo_green_dark</item>
                </style>






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 2 '16 at 22:08









                edwoollard

                10.1k63263




                10.1k63263










                answered Jul 11 '15 at 7:02









                Yogesh RathiYogesh Rathi

                3,89933260




                3,89933260













                • Please edit your answer with your example and don't post it as a comment

                  – bish
                  Jul 11 '15 at 7:24






                • 4





                  Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

                  – user3829751
                  Oct 6 '15 at 19:16













                • this changes the colorAccent, it's not what it was asked

                  – Alberto M
                  Jul 27 '16 at 13:24











                • On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

                  – Slava
                  May 15 '17 at 17:53



















                • Please edit your answer with your example and don't post it as a comment

                  – bish
                  Jul 11 '15 at 7:24






                • 4





                  Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

                  – user3829751
                  Oct 6 '15 at 19:16













                • this changes the colorAccent, it's not what it was asked

                  – Alberto M
                  Jul 27 '16 at 13:24











                • On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

                  – Slava
                  May 15 '17 at 17:53

















                Please edit your answer with your example and don't post it as a comment

                – bish
                Jul 11 '15 at 7:24





                Please edit your answer with your example and don't post it as a comment

                – bish
                Jul 11 '15 at 7:24




                4




                4





                Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

                – user3829751
                Oct 6 '15 at 19:16







                Slight correction: It's <item name="android:colorAccent></item>. Also, this is only available from API 21 and up.

                – user3829751
                Oct 6 '15 at 19:16















                this changes the colorAccent, it's not what it was asked

                – Alberto M
                Jul 27 '16 at 13:24





                this changes the colorAccent, it's not what it was asked

                – Alberto M
                Jul 27 '16 at 13:24













                On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

                – Slava
                May 15 '17 at 17:53





                On Galaxy S3 it changes only checked state of a CheckBox. But unchecked state is still the same.

                – Slava
                May 15 '17 at 17:53











                11














                I would suggest to use he style approach in android as the way to configure built-in android views, add new style in your project:



                <style name="yourStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">your_color</item> <!-- for uncheck state -->
                <item name="android:textColorSecondary">your color</item> <!-- for check state -->
                </style>


                and add assign this style to the theme of the checkbox:
                android:theme="@style/youStyle"



                hope this helps.






                share|improve this answer
























                • agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 1





                  This is a repeat of Amro elaswar's answer from 9 months earlier.

                  – jk7
                  Feb 9 '18 at 19:32











                • This is the kind of solution that is A REAL SOLUTION.

                  – Iharob Al Asimi
                  Jun 20 '18 at 17:42











                • It works for below 21 also. Thanks

                  – niketshah09
                  Oct 4 '18 at 9:02


















                11














                I would suggest to use he style approach in android as the way to configure built-in android views, add new style in your project:



                <style name="yourStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">your_color</item> <!-- for uncheck state -->
                <item name="android:textColorSecondary">your color</item> <!-- for check state -->
                </style>


                and add assign this style to the theme of the checkbox:
                android:theme="@style/youStyle"



                hope this helps.






                share|improve this answer
























                • agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 1





                  This is a repeat of Amro elaswar's answer from 9 months earlier.

                  – jk7
                  Feb 9 '18 at 19:32











                • This is the kind of solution that is A REAL SOLUTION.

                  – Iharob Al Asimi
                  Jun 20 '18 at 17:42











                • It works for below 21 also. Thanks

                  – niketshah09
                  Oct 4 '18 at 9:02
















                11












                11








                11







                I would suggest to use he style approach in android as the way to configure built-in android views, add new style in your project:



                <style name="yourStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">your_color</item> <!-- for uncheck state -->
                <item name="android:textColorSecondary">your color</item> <!-- for check state -->
                </style>


                and add assign this style to the theme of the checkbox:
                android:theme="@style/youStyle"



                hope this helps.






                share|improve this answer













                I would suggest to use he style approach in android as the way to configure built-in android views, add new style in your project:



                <style name="yourStyle" parent="Base.Theme.AppCompat">
                <item name="colorAccent">your_color</item> <!-- for uncheck state -->
                <item name="android:textColorSecondary">your color</item> <!-- for check state -->
                </style>


                and add assign this style to the theme of the checkbox:
                android:theme="@style/youStyle"



                hope this helps.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 30 '17 at 12:21









                Bahadin KhaliliehBahadin Khalilieh

                11113




                11113













                • agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 1





                  This is a repeat of Amro elaswar's answer from 9 months earlier.

                  – jk7
                  Feb 9 '18 at 19:32











                • This is the kind of solution that is A REAL SOLUTION.

                  – Iharob Al Asimi
                  Jun 20 '18 at 17:42











                • It works for below 21 also. Thanks

                  – niketshah09
                  Oct 4 '18 at 9:02





















                • agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

                  – Trung Le
                  Mar 14 '17 at 4:38






                • 1





                  This is a repeat of Amro elaswar's answer from 9 months earlier.

                  – jk7
                  Feb 9 '18 at 19:32











                • This is the kind of solution that is A REAL SOLUTION.

                  – Iharob Al Asimi
                  Jun 20 '18 at 17:42











                • It works for below 21 also. Thanks

                  – niketshah09
                  Oct 4 '18 at 9:02



















                agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

                – Trung Le
                Mar 14 '17 at 4:38





                agree with this solution, those attributes should work better with the default built-in android component without hassle on the drawable like the upvoted answer.

                – Trung Le
                Mar 14 '17 at 4:38




                1




                1





                This is a repeat of Amro elaswar's answer from 9 months earlier.

                – jk7
                Feb 9 '18 at 19:32





                This is a repeat of Amro elaswar's answer from 9 months earlier.

                – jk7
                Feb 9 '18 at 19:32













                This is the kind of solution that is A REAL SOLUTION.

                – Iharob Al Asimi
                Jun 20 '18 at 17:42





                This is the kind of solution that is A REAL SOLUTION.

                – Iharob Al Asimi
                Jun 20 '18 at 17:42













                It works for below 21 also. Thanks

                – niketshah09
                Oct 4 '18 at 9:02







                It works for below 21 also. Thanks

                – niketshah09
                Oct 4 '18 at 9:02













                6














                Me faced same problem, I got a solution using below technic. Copy the btn_check.xml from android-sdk/platforms/android-#(version)/data/res/drawable to your project's drawable folder and change the 'on' and 'off' image states to your custom images.

                Then your xml will just need android:button="@drawable/btn_check"



                <CheckBox
                android:button="@drawable/btn_check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true" />


                If you want to use different default Android icons, you can use:



                android:button="@android:drawable/..."





                share|improve this answer


























                • Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

                  – Gene Bo
                  Apr 23 '15 at 16:24






                • 1





                  There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

                  – Gene Bo
                  Apr 23 '15 at 18:27
















                6














                Me faced same problem, I got a solution using below technic. Copy the btn_check.xml from android-sdk/platforms/android-#(version)/data/res/drawable to your project's drawable folder and change the 'on' and 'off' image states to your custom images.

                Then your xml will just need android:button="@drawable/btn_check"



                <CheckBox
                android:button="@drawable/btn_check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true" />


                If you want to use different default Android icons, you can use:



                android:button="@android:drawable/..."





                share|improve this answer


























                • Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

                  – Gene Bo
                  Apr 23 '15 at 16:24






                • 1





                  There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

                  – Gene Bo
                  Apr 23 '15 at 18:27














                6












                6








                6







                Me faced same problem, I got a solution using below technic. Copy the btn_check.xml from android-sdk/platforms/android-#(version)/data/res/drawable to your project's drawable folder and change the 'on' and 'off' image states to your custom images.

                Then your xml will just need android:button="@drawable/btn_check"



                <CheckBox
                android:button="@drawable/btn_check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true" />


                If you want to use different default Android icons, you can use:



                android:button="@android:drawable/..."





                share|improve this answer















                Me faced same problem, I got a solution using below technic. Copy the btn_check.xml from android-sdk/platforms/android-#(version)/data/res/drawable to your project's drawable folder and change the 'on' and 'off' image states to your custom images.

                Then your xml will just need android:button="@drawable/btn_check"



                <CheckBox
                android:button="@drawable/btn_check"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true" />


                If you want to use different default Android icons, you can use:



                android:button="@android:drawable/..."






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 24 '15 at 16:47









                JJD

                25.7k36154255




                25.7k36154255










                answered Jul 16 '13 at 9:53









                sravansravan

                4,37512533




                4,37512533













                • Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

                  – Gene Bo
                  Apr 23 '15 at 16:24






                • 1





                  There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

                  – Gene Bo
                  Apr 23 '15 at 18:27



















                • Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

                  – Gene Bo
                  Apr 23 '15 at 16:24






                • 1





                  There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

                  – Gene Bo
                  Apr 23 '15 at 18:27

















                Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

                – Gene Bo
                Apr 23 '15 at 16:24





                Great answer - much easier than creating custom xml .. thanks! For me, I have a gray background and the checkbox border was not visible. I added this and you can see it now: android:button="@android:drawable/checkbox_off_background"

                – Gene Bo
                Apr 23 '15 at 16:24




                1




                1





                There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

                – Gene Bo
                Apr 23 '15 at 18:27





                There's actually a bit more to using this approach than I realized .. but still a nice option. I have added details below stackoverflow.com/a/29831532/2162226

                – Gene Bo
                Apr 23 '15 at 18:27











                6














                buttonTint worked for me try



                android:buttonTint="@color/white"



                <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:id="@+id/agreeCheckBox"
                android:text="@string/i_agree_to_terms_s"
                android:buttonTint="@color/white"
                android:layout_below="@+id/avoid_spam_text"/>





                share|improve this answer




























                  6














                  buttonTint worked for me try



                  android:buttonTint="@color/white"



                  <CheckBox
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerHorizontal="true"
                  android:id="@+id/agreeCheckBox"
                  android:text="@string/i_agree_to_terms_s"
                  android:buttonTint="@color/white"
                  android:layout_below="@+id/avoid_spam_text"/>





                  share|improve this answer


























                    6












                    6








                    6







                    buttonTint worked for me try



                    android:buttonTint="@color/white"



                    <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:id="@+id/agreeCheckBox"
                    android:text="@string/i_agree_to_terms_s"
                    android:buttonTint="@color/white"
                    android:layout_below="@+id/avoid_spam_text"/>





                    share|improve this answer













                    buttonTint worked for me try



                    android:buttonTint="@color/white"



                    <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:id="@+id/agreeCheckBox"
                    android:text="@string/i_agree_to_terms_s"
                    android:buttonTint="@color/white"
                    android:layout_below="@+id/avoid_spam_text"/>






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 5 '18 at 10:50









                    saigopisaigopi

                    3,8112523




                    3,8112523























                        3














                        You can change checkbox color using singe line of code



                        android:buttonTint="@color/app_color" //whatever color






                        share|improve this answer






























                          3














                          You can change checkbox color using singe line of code



                          android:buttonTint="@color/app_color" //whatever color






                          share|improve this answer




























                            3












                            3








                            3







                            You can change checkbox color using singe line of code



                            android:buttonTint="@color/app_color" //whatever color






                            share|improve this answer















                            You can change checkbox color using singe line of code



                            android:buttonTint="@color/app_color" //whatever color







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 15 '18 at 12:13









                            Milad Bahmanabadi

                            835718




                            835718










                            answered Aug 18 '18 at 6:14









                            Kishore ReddyKishore Reddy

                            859810




                            859810























                                2














                                you can create your own xml in drawable and use this as android:background="@drawable/your_xml"



                                in that you can give border corner everything






                                <item>
                                <shape>
                                <gradient

                                android:endColor="#fff"
                                android:startColor="#fff"/>
                                <corners
                                android:radius="2dp"/>
                                <stroke
                                android:width="15dp"
                                android:color="#0013669e"/>

                                </shape>
                                </item>







                                share|improve this answer



















                                • 1





                                  Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

                                  – Mike Poole
                                  Jan 10 '18 at 7:24
















                                2














                                you can create your own xml in drawable and use this as android:background="@drawable/your_xml"



                                in that you can give border corner everything






                                <item>
                                <shape>
                                <gradient

                                android:endColor="#fff"
                                android:startColor="#fff"/>
                                <corners
                                android:radius="2dp"/>
                                <stroke
                                android:width="15dp"
                                android:color="#0013669e"/>

                                </shape>
                                </item>







                                share|improve this answer



















                                • 1





                                  Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

                                  – Mike Poole
                                  Jan 10 '18 at 7:24














                                2












                                2








                                2







                                you can create your own xml in drawable and use this as android:background="@drawable/your_xml"



                                in that you can give border corner everything






                                <item>
                                <shape>
                                <gradient

                                android:endColor="#fff"
                                android:startColor="#fff"/>
                                <corners
                                android:radius="2dp"/>
                                <stroke
                                android:width="15dp"
                                android:color="#0013669e"/>

                                </shape>
                                </item>







                                share|improve this answer













                                you can create your own xml in drawable and use this as android:background="@drawable/your_xml"



                                in that you can give border corner everything






                                <item>
                                <shape>
                                <gradient

                                android:endColor="#fff"
                                android:startColor="#fff"/>
                                <corners
                                android:radius="2dp"/>
                                <stroke
                                android:width="15dp"
                                android:color="#0013669e"/>

                                </shape>
                                </item>








                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Sep 18 '16 at 18:28









                                abhiruchi vijayabhiruchi vijay

                                493




                                493








                                • 1





                                  Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

                                  – Mike Poole
                                  Jan 10 '18 at 7:24














                                • 1





                                  Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

                                  – Mike Poole
                                  Jan 10 '18 at 7:24








                                1




                                1





                                Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

                                – Mike Poole
                                Jan 10 '18 at 7:24





                                Whilst it is noice to know about drawable vector graphics this answer does not answer the OP's question about the button tint.

                                – Mike Poole
                                Jan 10 '18 at 7:24











                                2














                                Hi This is the theme code for both Dark Theme and Light Theme.



                                <attr name="buttonsearch_picture" format="reference"/>
                                <attr name="buttonrefresh_picture" format="reference"/>

                                <style name="Theme.Light" parent="Theme.AppCompat.Light.NoActionBar">
                                <item name="android:windowNoTitle">true</item>
                                <item name="android:windowBackground">@color/white</item>
                                <item name="android:windowActionBar">false</item>
                                <item name="android:textColorPrimary">@color/black</item>
                                <item name="android:textColorSecondary">@color/black</item>
                                <item name="android:textColor">@color/material_gray_800</item>
                                <item name="actionOverflowButtonStyle">@style/LightOverflowButtonStyle</item>
                                <item name="buttonsearch_picture">@drawable/ic_search_black</item>
                                <item name="buttonrefresh_picture">@drawable/ic_refresh_black</item>
                                </style>

                                <style name="Theme.Dark" parent="Theme.AppCompat.NoActionBar">
                                <item name="android:windowNoTitle">true</item>
                                <item name="android:windowBackground">@color/white</item>
                                <item name="android:windowActionBar">false</item>
                                <item name="android:textColorPrimary">@color/white</item>
                                <item name="android:textColorSecondary">@color/material_gray_500</item>
                                <item name="android:textColor">@color/material_gray_800</item>
                                <item name="actionOverflowButtonStyle">@style/DarkOverflowButtonStyle</item>
                                <item name="buttonsearch_picture">@drawable/ic_search_white</item>
                                <item name="buttonrefresh_picture">@drawable/ic_refresh_white</item>
                                <item name="android:colorBackground">#ffffff</item>
                                <item name="android:alertDialogTheme">@style/LightDialogTheme</item>
                                <item name="android:alertDialogStyle">@style/LightDialogTheme</item>
                                <!-- <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>-->
                                <item name="android:popupMenuStyle">@style/PopupMenu</item>
                                </style>


                                If you want to change checkbox color then "colorAccent" attribute will use for checked state and "android:textColorSecondary" will use for unchecking state.



                                "actionOverflowButtonStyle" will use for change the color of overflow icon in the Action bar.



                                "buttonsearch_picture" attribute will use for change tint color of Action Button in Action Bar.This is custom Attribute in style.xml



                                <attr name="buttonsearch_picture" format="reference"/>


                                Same is for refresh button which i am using in my app.



                                "android:popupMenuStyle" attribute is using to get Light theme popup menu style in Dark theme.



                                <style name="PopupMenu" parent="Theme.AppCompat.Light.NoActionBar">
                                </style>


                                And this is toolbar Code which I am using in my Rocks Player App.



                                 <android.support.v7.widget.Toolbar
                                android:id="@+id/toolbar"
                                app:contentInsetStart="0dp"
                                android:title="Rocks Player"
                                android:layout_width="match_parent"
                                android:elevation="4dp"
                                android:layout_height="48dp"
                                app:layout_scrollFlags="scroll|enterAlways"
                                android:minHeight="48dp"
                                app:titleTextAppearance="@style/Toolbar.TitleText"
                                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                                android:background="?attr/colorPrimary"
                                >
                                </android.support.v7.widget.Toolbar>


                                Themes:-



                                 <style name="AppTheme0" parent="Theme.Light">
                                <item name="colorPrimary">#ffffff</item>
                                <item name="colorPrimaryDark">#cccccc</item>
                                <item name="colorAccent">#0294ff</item>
                                </style>

                                <style name="AppTheme1" parent="Theme.Dark">
                                <item name="colorPrimary">#4161b2</item>
                                <item name="colorPrimaryDark">#4161b2</item>
                                <item name="colorAccent">#4161b2</item>
                                </style>





                                share|improve this answer




























                                  2














                                  Hi This is the theme code for both Dark Theme and Light Theme.



                                  <attr name="buttonsearch_picture" format="reference"/>
                                  <attr name="buttonrefresh_picture" format="reference"/>

                                  <style name="Theme.Light" parent="Theme.AppCompat.Light.NoActionBar">
                                  <item name="android:windowNoTitle">true</item>
                                  <item name="android:windowBackground">@color/white</item>
                                  <item name="android:windowActionBar">false</item>
                                  <item name="android:textColorPrimary">@color/black</item>
                                  <item name="android:textColorSecondary">@color/black</item>
                                  <item name="android:textColor">@color/material_gray_800</item>
                                  <item name="actionOverflowButtonStyle">@style/LightOverflowButtonStyle</item>
                                  <item name="buttonsearch_picture">@drawable/ic_search_black</item>
                                  <item name="buttonrefresh_picture">@drawable/ic_refresh_black</item>
                                  </style>

                                  <style name="Theme.Dark" parent="Theme.AppCompat.NoActionBar">
                                  <item name="android:windowNoTitle">true</item>
                                  <item name="android:windowBackground">@color/white</item>
                                  <item name="android:windowActionBar">false</item>
                                  <item name="android:textColorPrimary">@color/white</item>
                                  <item name="android:textColorSecondary">@color/material_gray_500</item>
                                  <item name="android:textColor">@color/material_gray_800</item>
                                  <item name="actionOverflowButtonStyle">@style/DarkOverflowButtonStyle</item>
                                  <item name="buttonsearch_picture">@drawable/ic_search_white</item>
                                  <item name="buttonrefresh_picture">@drawable/ic_refresh_white</item>
                                  <item name="android:colorBackground">#ffffff</item>
                                  <item name="android:alertDialogTheme">@style/LightDialogTheme</item>
                                  <item name="android:alertDialogStyle">@style/LightDialogTheme</item>
                                  <!-- <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>-->
                                  <item name="android:popupMenuStyle">@style/PopupMenu</item>
                                  </style>


                                  If you want to change checkbox color then "colorAccent" attribute will use for checked state and "android:textColorSecondary" will use for unchecking state.



                                  "actionOverflowButtonStyle" will use for change the color of overflow icon in the Action bar.



                                  "buttonsearch_picture" attribute will use for change tint color of Action Button in Action Bar.This is custom Attribute in style.xml



                                  <attr name="buttonsearch_picture" format="reference"/>


                                  Same is for refresh button which i am using in my app.



                                  "android:popupMenuStyle" attribute is using to get Light theme popup menu style in Dark theme.



                                  <style name="PopupMenu" parent="Theme.AppCompat.Light.NoActionBar">
                                  </style>


                                  And this is toolbar Code which I am using in my Rocks Player App.



                                   <android.support.v7.widget.Toolbar
                                  android:id="@+id/toolbar"
                                  app:contentInsetStart="0dp"
                                  android:title="Rocks Player"
                                  android:layout_width="match_parent"
                                  android:elevation="4dp"
                                  android:layout_height="48dp"
                                  app:layout_scrollFlags="scroll|enterAlways"
                                  android:minHeight="48dp"
                                  app:titleTextAppearance="@style/Toolbar.TitleText"
                                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                                  android:background="?attr/colorPrimary"
                                  >
                                  </android.support.v7.widget.Toolbar>


                                  Themes:-



                                   <style name="AppTheme0" parent="Theme.Light">
                                  <item name="colorPrimary">#ffffff</item>
                                  <item name="colorPrimaryDark">#cccccc</item>
                                  <item name="colorAccent">#0294ff</item>
                                  </style>

                                  <style name="AppTheme1" parent="Theme.Dark">
                                  <item name="colorPrimary">#4161b2</item>
                                  <item name="colorPrimaryDark">#4161b2</item>
                                  <item name="colorAccent">#4161b2</item>
                                  </style>





                                  share|improve this answer


























                                    2












                                    2








                                    2







                                    Hi This is the theme code for both Dark Theme and Light Theme.



                                    <attr name="buttonsearch_picture" format="reference"/>
                                    <attr name="buttonrefresh_picture" format="reference"/>

                                    <style name="Theme.Light" parent="Theme.AppCompat.Light.NoActionBar">
                                    <item name="android:windowNoTitle">true</item>
                                    <item name="android:windowBackground">@color/white</item>
                                    <item name="android:windowActionBar">false</item>
                                    <item name="android:textColorPrimary">@color/black</item>
                                    <item name="android:textColorSecondary">@color/black</item>
                                    <item name="android:textColor">@color/material_gray_800</item>
                                    <item name="actionOverflowButtonStyle">@style/LightOverflowButtonStyle</item>
                                    <item name="buttonsearch_picture">@drawable/ic_search_black</item>
                                    <item name="buttonrefresh_picture">@drawable/ic_refresh_black</item>
                                    </style>

                                    <style name="Theme.Dark" parent="Theme.AppCompat.NoActionBar">
                                    <item name="android:windowNoTitle">true</item>
                                    <item name="android:windowBackground">@color/white</item>
                                    <item name="android:windowActionBar">false</item>
                                    <item name="android:textColorPrimary">@color/white</item>
                                    <item name="android:textColorSecondary">@color/material_gray_500</item>
                                    <item name="android:textColor">@color/material_gray_800</item>
                                    <item name="actionOverflowButtonStyle">@style/DarkOverflowButtonStyle</item>
                                    <item name="buttonsearch_picture">@drawable/ic_search_white</item>
                                    <item name="buttonrefresh_picture">@drawable/ic_refresh_white</item>
                                    <item name="android:colorBackground">#ffffff</item>
                                    <item name="android:alertDialogTheme">@style/LightDialogTheme</item>
                                    <item name="android:alertDialogStyle">@style/LightDialogTheme</item>
                                    <!-- <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>-->
                                    <item name="android:popupMenuStyle">@style/PopupMenu</item>
                                    </style>


                                    If you want to change checkbox color then "colorAccent" attribute will use for checked state and "android:textColorSecondary" will use for unchecking state.



                                    "actionOverflowButtonStyle" will use for change the color of overflow icon in the Action bar.



                                    "buttonsearch_picture" attribute will use for change tint color of Action Button in Action Bar.This is custom Attribute in style.xml



                                    <attr name="buttonsearch_picture" format="reference"/>


                                    Same is for refresh button which i am using in my app.



                                    "android:popupMenuStyle" attribute is using to get Light theme popup menu style in Dark theme.



                                    <style name="PopupMenu" parent="Theme.AppCompat.Light.NoActionBar">
                                    </style>


                                    And this is toolbar Code which I am using in my Rocks Player App.



                                     <android.support.v7.widget.Toolbar
                                    android:id="@+id/toolbar"
                                    app:contentInsetStart="0dp"
                                    android:title="Rocks Player"
                                    android:layout_width="match_parent"
                                    android:elevation="4dp"
                                    android:layout_height="48dp"
                                    app:layout_scrollFlags="scroll|enterAlways"
                                    android:minHeight="48dp"
                                    app:titleTextAppearance="@style/Toolbar.TitleText"
                                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                                    android:background="?attr/colorPrimary"
                                    >
                                    </android.support.v7.widget.Toolbar>


                                    Themes:-



                                     <style name="AppTheme0" parent="Theme.Light">
                                    <item name="colorPrimary">#ffffff</item>
                                    <item name="colorPrimaryDark">#cccccc</item>
                                    <item name="colorAccent">#0294ff</item>
                                    </style>

                                    <style name="AppTheme1" parent="Theme.Dark">
                                    <item name="colorPrimary">#4161b2</item>
                                    <item name="colorPrimaryDark">#4161b2</item>
                                    <item name="colorAccent">#4161b2</item>
                                    </style>





                                    share|improve this answer













                                    Hi This is the theme code for both Dark Theme and Light Theme.



                                    <attr name="buttonsearch_picture" format="reference"/>
                                    <attr name="buttonrefresh_picture" format="reference"/>

                                    <style name="Theme.Light" parent="Theme.AppCompat.Light.NoActionBar">
                                    <item name="android:windowNoTitle">true</item>
                                    <item name="android:windowBackground">@color/white</item>
                                    <item name="android:windowActionBar">false</item>
                                    <item name="android:textColorPrimary">@color/black</item>
                                    <item name="android:textColorSecondary">@color/black</item>
                                    <item name="android:textColor">@color/material_gray_800</item>
                                    <item name="actionOverflowButtonStyle">@style/LightOverflowButtonStyle</item>
                                    <item name="buttonsearch_picture">@drawable/ic_search_black</item>
                                    <item name="buttonrefresh_picture">@drawable/ic_refresh_black</item>
                                    </style>

                                    <style name="Theme.Dark" parent="Theme.AppCompat.NoActionBar">
                                    <item name="android:windowNoTitle">true</item>
                                    <item name="android:windowBackground">@color/white</item>
                                    <item name="android:windowActionBar">false</item>
                                    <item name="android:textColorPrimary">@color/white</item>
                                    <item name="android:textColorSecondary">@color/material_gray_500</item>
                                    <item name="android:textColor">@color/material_gray_800</item>
                                    <item name="actionOverflowButtonStyle">@style/DarkOverflowButtonStyle</item>
                                    <item name="buttonsearch_picture">@drawable/ic_search_white</item>
                                    <item name="buttonrefresh_picture">@drawable/ic_refresh_white</item>
                                    <item name="android:colorBackground">#ffffff</item>
                                    <item name="android:alertDialogTheme">@style/LightDialogTheme</item>
                                    <item name="android:alertDialogStyle">@style/LightDialogTheme</item>
                                    <!-- <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>-->
                                    <item name="android:popupMenuStyle">@style/PopupMenu</item>
                                    </style>


                                    If you want to change checkbox color then "colorAccent" attribute will use for checked state and "android:textColorSecondary" will use for unchecking state.



                                    "actionOverflowButtonStyle" will use for change the color of overflow icon in the Action bar.



                                    "buttonsearch_picture" attribute will use for change tint color of Action Button in Action Bar.This is custom Attribute in style.xml



                                    <attr name="buttonsearch_picture" format="reference"/>


                                    Same is for refresh button which i am using in my app.



                                    "android:popupMenuStyle" attribute is using to get Light theme popup menu style in Dark theme.



                                    <style name="PopupMenu" parent="Theme.AppCompat.Light.NoActionBar">
                                    </style>


                                    And this is toolbar Code which I am using in my Rocks Player App.



                                     <android.support.v7.widget.Toolbar
                                    android:id="@+id/toolbar"
                                    app:contentInsetStart="0dp"
                                    android:title="Rocks Player"
                                    android:layout_width="match_parent"
                                    android:elevation="4dp"
                                    android:layout_height="48dp"
                                    app:layout_scrollFlags="scroll|enterAlways"
                                    android:minHeight="48dp"
                                    app:titleTextAppearance="@style/Toolbar.TitleText"
                                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                                    android:background="?attr/colorPrimary"
                                    >
                                    </android.support.v7.widget.Toolbar>


                                    Themes:-



                                     <style name="AppTheme0" parent="Theme.Light">
                                    <item name="colorPrimary">#ffffff</item>
                                    <item name="colorPrimaryDark">#cccccc</item>
                                    <item name="colorAccent">#0294ff</item>
                                    </style>

                                    <style name="AppTheme1" parent="Theme.Dark">
                                    <item name="colorPrimary">#4161b2</item>
                                    <item name="colorPrimaryDark">#4161b2</item>
                                    <item name="colorAccent">#4161b2</item>
                                    </style>






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 1 '17 at 10:10









                                    Ashish SainiAshish Saini

                                    1,7081720




                                    1,7081720























                                        1














                                        create an xml Drawable resource file under res->drawable and name it, for example, checkbox_custom_01.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/checkbox_custom_01_checked_white_green_32" />
                                        <item
                                        android:state_checked="false"
                                        android:drawable="@drawable/checkbox_custom_01_unchecked_gray_32" />
                                        </selector>


                                        Upload your custom checkbox image files (i recommend png) to your res->drawable folder.



                                        Then go in your layout file and change your checkbox to



                                        <CheckBox
                                        android:id="@+id/checkBox1"
                                        android:button="@drawable/checkbox_custom_01"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content"
                                        android:layout_alignParentLeft="true"
                                        android:focusable="false"
                                        android:focusableInTouchMode="false"
                                        android:text="CheckBox"
                                        android:textSize="32dip"/>


                                        you may customize anything, as long as android:button points to the correct XML file you created before.



                                        NOTE TO NEWBIES: though it is not mandatory, it is nevertheless good practice to name your checkbox with a unique id throughout your whole layout tree.






                                        share|improve this answer




























                                          1














                                          create an xml Drawable resource file under res->drawable and name it, for example, checkbox_custom_01.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/checkbox_custom_01_checked_white_green_32" />
                                          <item
                                          android:state_checked="false"
                                          android:drawable="@drawable/checkbox_custom_01_unchecked_gray_32" />
                                          </selector>


                                          Upload your custom checkbox image files (i recommend png) to your res->drawable folder.



                                          Then go in your layout file and change your checkbox to



                                          <CheckBox
                                          android:id="@+id/checkBox1"
                                          android:button="@drawable/checkbox_custom_01"
                                          android:layout_width="wrap_content"
                                          android:layout_height="wrap_content"
                                          android:layout_alignParentLeft="true"
                                          android:focusable="false"
                                          android:focusableInTouchMode="false"
                                          android:text="CheckBox"
                                          android:textSize="32dip"/>


                                          you may customize anything, as long as android:button points to the correct XML file you created before.



                                          NOTE TO NEWBIES: though it is not mandatory, it is nevertheless good practice to name your checkbox with a unique id throughout your whole layout tree.






                                          share|improve this answer


























                                            1












                                            1








                                            1







                                            create an xml Drawable resource file under res->drawable and name it, for example, checkbox_custom_01.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/checkbox_custom_01_checked_white_green_32" />
                                            <item
                                            android:state_checked="false"
                                            android:drawable="@drawable/checkbox_custom_01_unchecked_gray_32" />
                                            </selector>


                                            Upload your custom checkbox image files (i recommend png) to your res->drawable folder.



                                            Then go in your layout file and change your checkbox to



                                            <CheckBox
                                            android:id="@+id/checkBox1"
                                            android:button="@drawable/checkbox_custom_01"
                                            android:layout_width="wrap_content"
                                            android:layout_height="wrap_content"
                                            android:layout_alignParentLeft="true"
                                            android:focusable="false"
                                            android:focusableInTouchMode="false"
                                            android:text="CheckBox"
                                            android:textSize="32dip"/>


                                            you may customize anything, as long as android:button points to the correct XML file you created before.



                                            NOTE TO NEWBIES: though it is not mandatory, it is nevertheless good practice to name your checkbox with a unique id throughout your whole layout tree.






                                            share|improve this answer













                                            create an xml Drawable resource file under res->drawable and name it, for example, checkbox_custom_01.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/checkbox_custom_01_checked_white_green_32" />
                                            <item
                                            android:state_checked="false"
                                            android:drawable="@drawable/checkbox_custom_01_unchecked_gray_32" />
                                            </selector>


                                            Upload your custom checkbox image files (i recommend png) to your res->drawable folder.



                                            Then go in your layout file and change your checkbox to



                                            <CheckBox
                                            android:id="@+id/checkBox1"
                                            android:button="@drawable/checkbox_custom_01"
                                            android:layout_width="wrap_content"
                                            android:layout_height="wrap_content"
                                            android:layout_alignParentLeft="true"
                                            android:focusable="false"
                                            android:focusableInTouchMode="false"
                                            android:text="CheckBox"
                                            android:textSize="32dip"/>


                                            you may customize anything, as long as android:button points to the correct XML file you created before.



                                            NOTE TO NEWBIES: though it is not mandatory, it is nevertheless good practice to name your checkbox with a unique id throughout your whole layout tree.







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Oct 19 '16 at 11:35









                                            tony giltony gil

                                            7,96245885




                                            7,96245885























                                                0














                                                You can change the background color of the <CheckBox> by embedding it inside a <LinearLayout>. Then change the background color of <LinearLayout> to the color you want.






                                                share|improve this answer


























                                                • The question is about the color of the checkbox and not the background

                                                  – Zvi
                                                  Jul 16 '16 at 17:30
















                                                0














                                                You can change the background color of the <CheckBox> by embedding it inside a <LinearLayout>. Then change the background color of <LinearLayout> to the color you want.






                                                share|improve this answer


























                                                • The question is about the color of the checkbox and not the background

                                                  – Zvi
                                                  Jul 16 '16 at 17:30














                                                0












                                                0








                                                0







                                                You can change the background color of the <CheckBox> by embedding it inside a <LinearLayout>. Then change the background color of <LinearLayout> to the color you want.






                                                share|improve this answer















                                                You can change the background color of the <CheckBox> by embedding it inside a <LinearLayout>. Then change the background color of <LinearLayout> to the color you want.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Jan 25 '12 at 14:52









                                                Giulio Piancastelli

                                                10.2k53354




                                                10.2k53354










                                                answered Jun 14 '11 at 4:11









                                                mellowgmellowg

                                                80631118




                                                80631118













                                                • The question is about the color of the checkbox and not the background

                                                  – Zvi
                                                  Jul 16 '16 at 17:30



















                                                • The question is about the color of the checkbox and not the background

                                                  – Zvi
                                                  Jul 16 '16 at 17:30

















                                                The question is about the color of the checkbox and not the background

                                                – Zvi
                                                Jul 16 '16 at 17:30





                                                The question is about the color of the checkbox and not the background

                                                – Zvi
                                                Jul 16 '16 at 17:30











                                                0














                                                You should try below code. It is working for me.



                                                <selector xmlns:android="http://schemas.android.com/apk/res/android">
                                                <item android:drawable="@drawable/checked"
                                                android:state_checked="true">
                                                <color android:color="@color/yello" />
                                                </item>
                                                <!-- checked -->
                                                <item android:drawable="@drawable/unchecked"
                                                android:state_checked="false">
                                                <color android:color="@color/black"></color>
                                                </item>
                                                <!-- unchecked -->
                                                <item android:drawable="@drawable/checked"
                                                android:state_focused="true">
                                                <color android:color="@color/yello"></color>
                                                </item>
                                                <!-- on focus -->
                                                <item android:drawable="@drawable/unchecked">
                                                <color android:color="@color/black"></color>
                                                </item>
                                                <!-- default -->
                                                </selector>


                                                and CheckBox



                                                <CheckBox
                                                Button="@style/currentcy_check_box_style"
                                                android:layout_width="wrap_content"
                                                android:layout_height="wrap_content"
                                                android:paddingLeft="20dp"
                                                android:text="@string/step_one_currency_aud" />





                                                share|improve this answer






























                                                  0














                                                  You should try below code. It is working for me.



                                                  <selector xmlns:android="http://schemas.android.com/apk/res/android">
                                                  <item android:drawable="@drawable/checked"
                                                  android:state_checked="true">
                                                  <color android:color="@color/yello" />
                                                  </item>
                                                  <!-- checked -->
                                                  <item android:drawable="@drawable/unchecked"
                                                  android:state_checked="false">
                                                  <color android:color="@color/black"></color>
                                                  </item>
                                                  <!-- unchecked -->
                                                  <item android:drawable="@drawable/checked"
                                                  android:state_focused="true">
                                                  <color android:color="@color/yello"></color>
                                                  </item>
                                                  <!-- on focus -->
                                                  <item android:drawable="@drawable/unchecked">
                                                  <color android:color="@color/black"></color>
                                                  </item>
                                                  <!-- default -->
                                                  </selector>


                                                  and CheckBox



                                                  <CheckBox
                                                  Button="@style/currentcy_check_box_style"
                                                  android:layout_width="wrap_content"
                                                  android:layout_height="wrap_content"
                                                  android:paddingLeft="20dp"
                                                  android:text="@string/step_one_currency_aud" />





                                                  share|improve this answer




























                                                    0












                                                    0








                                                    0







                                                    You should try below code. It is working for me.



                                                    <selector xmlns:android="http://schemas.android.com/apk/res/android">
                                                    <item android:drawable="@drawable/checked"
                                                    android:state_checked="true">
                                                    <color android:color="@color/yello" />
                                                    </item>
                                                    <!-- checked -->
                                                    <item android:drawable="@drawable/unchecked"
                                                    android:state_checked="false">
                                                    <color android:color="@color/black"></color>
                                                    </item>
                                                    <!-- unchecked -->
                                                    <item android:drawable="@drawable/checked"
                                                    android:state_focused="true">
                                                    <color android:color="@color/yello"></color>
                                                    </item>
                                                    <!-- on focus -->
                                                    <item android:drawable="@drawable/unchecked">
                                                    <color android:color="@color/black"></color>
                                                    </item>
                                                    <!-- default -->
                                                    </selector>


                                                    and CheckBox



                                                    <CheckBox
                                                    Button="@style/currentcy_check_box_style"
                                                    android:layout_width="wrap_content"
                                                    android:layout_height="wrap_content"
                                                    android:paddingLeft="20dp"
                                                    android:text="@string/step_one_currency_aud" />





                                                    share|improve this answer















                                                    You should try below code. It is working for me.



                                                    <selector xmlns:android="http://schemas.android.com/apk/res/android">
                                                    <item android:drawable="@drawable/checked"
                                                    android:state_checked="true">
                                                    <color android:color="@color/yello" />
                                                    </item>
                                                    <!-- checked -->
                                                    <item android:drawable="@drawable/unchecked"
                                                    android:state_checked="false">
                                                    <color android:color="@color/black"></color>
                                                    </item>
                                                    <!-- unchecked -->
                                                    <item android:drawable="@drawable/checked"
                                                    android:state_focused="true">
                                                    <color android:color="@color/yello"></color>
                                                    </item>
                                                    <!-- on focus -->
                                                    <item android:drawable="@drawable/unchecked">
                                                    <color android:color="@color/black"></color>
                                                    </item>
                                                    <!-- default -->
                                                    </selector>


                                                    and CheckBox



                                                    <CheckBox
                                                    Button="@style/currentcy_check_box_style"
                                                    android:layout_width="wrap_content"
                                                    android:layout_height="wrap_content"
                                                    android:paddingLeft="20dp"
                                                    android:text="@string/step_one_currency_aud" />






                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited Feb 24 '15 at 16:45









                                                    JJD

                                                    25.7k36154255




                                                    25.7k36154255










                                                    answered Aug 14 '13 at 11:01









                                                    Imtiyaz KhalaniImtiyaz Khalani

                                                    1,7461126




                                                    1,7461126























                                                        0














                                                        If you are going to use the android icons, as described above ..



                                                        android:button="@android:drawable/..."


                                                        .. it's a nice option, but for this to work - I found you need to add toggle logic to show/hide the check mark, like this:



                                                            checkBoxShowPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                                                        // checkbox status is changed from uncheck to checked.
                                                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                                                        int btnDrawable = android.R.drawable.checkbox_off_background;

                                                        if (isChecked)
                                                        {
                                                        btnDrawable = android.R.drawable.checkbox_on_background;
                                                        }

                                                        checkBoxShowPwd.setButtonDrawable(btnDrawable);

                                                        }
                                                        });





                                                        share|improve this answer
























                                                        • Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

                                                          – jkincali
                                                          Feb 22 '17 at 16:09
















                                                        0














                                                        If you are going to use the android icons, as described above ..



                                                        android:button="@android:drawable/..."


                                                        .. it's a nice option, but for this to work - I found you need to add toggle logic to show/hide the check mark, like this:



                                                            checkBoxShowPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                                                        // checkbox status is changed from uncheck to checked.
                                                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                                                        int btnDrawable = android.R.drawable.checkbox_off_background;

                                                        if (isChecked)
                                                        {
                                                        btnDrawable = android.R.drawable.checkbox_on_background;
                                                        }

                                                        checkBoxShowPwd.setButtonDrawable(btnDrawable);

                                                        }
                                                        });





                                                        share|improve this answer
























                                                        • Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

                                                          – jkincali
                                                          Feb 22 '17 at 16:09














                                                        0












                                                        0








                                                        0







                                                        If you are going to use the android icons, as described above ..



                                                        android:button="@android:drawable/..."


                                                        .. it's a nice option, but for this to work - I found you need to add toggle logic to show/hide the check mark, like this:



                                                            checkBoxShowPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                                                        // checkbox status is changed from uncheck to checked.
                                                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                                                        int btnDrawable = android.R.drawable.checkbox_off_background;

                                                        if (isChecked)
                                                        {
                                                        btnDrawable = android.R.drawable.checkbox_on_background;
                                                        }

                                                        checkBoxShowPwd.setButtonDrawable(btnDrawable);

                                                        }
                                                        });





                                                        share|improve this answer













                                                        If you are going to use the android icons, as described above ..



                                                        android:button="@android:drawable/..."


                                                        .. it's a nice option, but for this to work - I found you need to add toggle logic to show/hide the check mark, like this:



                                                            checkBoxShowPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                                                        // checkbox status is changed from uncheck to checked.
                                                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                                                        int btnDrawable = android.R.drawable.checkbox_off_background;

                                                        if (isChecked)
                                                        {
                                                        btnDrawable = android.R.drawable.checkbox_on_background;
                                                        }

                                                        checkBoxShowPwd.setButtonDrawable(btnDrawable);

                                                        }
                                                        });






                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Apr 23 '15 at 18:26









                                                        Gene BoGene Bo

                                                        5,57944394




                                                        5,57944394













                                                        • Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

                                                          – jkincali
                                                          Feb 22 '17 at 16:09



















                                                        • Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

                                                          – jkincali
                                                          Feb 22 '17 at 16:09

















                                                        Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

                                                        – jkincali
                                                        Feb 22 '17 at 16:09





                                                        Well, this is extra work that really isn't necessary. In the drawable's xml file you supply references to on or off drawable resources for the selector. This automatically puts the correct drawable according to the checkbox's state.

                                                        – jkincali
                                                        Feb 22 '17 at 16:09











                                                        0














                                                        You can use the following two properties in "colors.xml"



                                                        <color name="colorControlNormal">#eeeeee</color>
                                                        <color name="colorControlActivated">#eeeeee</color>


                                                        colorControlNormal is for the normal view of checkbox, and colorControlActivated is for when the checkbox is checked.






                                                        share|improve this answer




























                                                          0














                                                          You can use the following two properties in "colors.xml"



                                                          <color name="colorControlNormal">#eeeeee</color>
                                                          <color name="colorControlActivated">#eeeeee</color>


                                                          colorControlNormal is for the normal view of checkbox, and colorControlActivated is for when the checkbox is checked.






                                                          share|improve this answer


























                                                            0












                                                            0








                                                            0







                                                            You can use the following two properties in "colors.xml"



                                                            <color name="colorControlNormal">#eeeeee</color>
                                                            <color name="colorControlActivated">#eeeeee</color>


                                                            colorControlNormal is for the normal view of checkbox, and colorControlActivated is for when the checkbox is checked.






                                                            share|improve this answer













                                                            You can use the following two properties in "colors.xml"



                                                            <color name="colorControlNormal">#eeeeee</color>
                                                            <color name="colorControlActivated">#eeeeee</color>


                                                            colorControlNormal is for the normal view of checkbox, and colorControlActivated is for when the checkbox is checked.







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Jul 1 '17 at 4:49









                                                            Tajveer Singh NijjarTajveer Singh Nijjar

                                                            361312




                                                            361312























                                                                0














                                                                100% robust approach.



                                                                In my case, I didn't have access to the XML layout source file, since I get Checkbox from a 3-rd party MaterialDialog lib.
                                                                So I have to solve this programmatically.




                                                                1. Create a ColorStateList in xml:


                                                                res/color/checkbox_tinit_dark_theme.xml:



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




                                                                1. Then apply it to the checkbox:



                                                                  ColorStateList darkStateList = ContextCompat.getColorStateList(getContext(), R.color.checkbox_tint_dark_theme);
                                                                  CompoundButtonCompat.setButtonTintList(checkbox, darkStateList);



                                                                P.S. In addition if someone is interested, here is how you can get your checkbox from MaterialDialog dialog (if you set it with .checkBoxPromptRes(...)):



                                                                CheckBox checkbox = (CheckBox) dialog.getView().findViewById(R.id.md_promptCheckbox);


                                                                Hope this helps.






                                                                share|improve this answer




























                                                                  0














                                                                  100% robust approach.



                                                                  In my case, I didn't have access to the XML layout source file, since I get Checkbox from a 3-rd party MaterialDialog lib.
                                                                  So I have to solve this programmatically.




                                                                  1. Create a ColorStateList in xml:


                                                                  res/color/checkbox_tinit_dark_theme.xml:



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




                                                                  1. Then apply it to the checkbox:



                                                                    ColorStateList darkStateList = ContextCompat.getColorStateList(getContext(), R.color.checkbox_tint_dark_theme);
                                                                    CompoundButtonCompat.setButtonTintList(checkbox, darkStateList);



                                                                  P.S. In addition if someone is interested, here is how you can get your checkbox from MaterialDialog dialog (if you set it with .checkBoxPromptRes(...)):



                                                                  CheckBox checkbox = (CheckBox) dialog.getView().findViewById(R.id.md_promptCheckbox);


                                                                  Hope this helps.






                                                                  share|improve this answer


























                                                                    0












                                                                    0








                                                                    0







                                                                    100% robust approach.



                                                                    In my case, I didn't have access to the XML layout source file, since I get Checkbox from a 3-rd party MaterialDialog lib.
                                                                    So I have to solve this programmatically.




                                                                    1. Create a ColorStateList in xml:


                                                                    res/color/checkbox_tinit_dark_theme.xml:



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




                                                                    1. Then apply it to the checkbox:



                                                                      ColorStateList darkStateList = ContextCompat.getColorStateList(getContext(), R.color.checkbox_tint_dark_theme);
                                                                      CompoundButtonCompat.setButtonTintList(checkbox, darkStateList);



                                                                    P.S. In addition if someone is interested, here is how you can get your checkbox from MaterialDialog dialog (if you set it with .checkBoxPromptRes(...)):



                                                                    CheckBox checkbox = (CheckBox) dialog.getView().findViewById(R.id.md_promptCheckbox);


                                                                    Hope this helps.






                                                                    share|improve this answer













                                                                    100% robust approach.



                                                                    In my case, I didn't have access to the XML layout source file, since I get Checkbox from a 3-rd party MaterialDialog lib.
                                                                    So I have to solve this programmatically.




                                                                    1. Create a ColorStateList in xml:


                                                                    res/color/checkbox_tinit_dark_theme.xml:



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




                                                                    1. Then apply it to the checkbox:



                                                                      ColorStateList darkStateList = ContextCompat.getColorStateList(getContext(), R.color.checkbox_tint_dark_theme);
                                                                      CompoundButtonCompat.setButtonTintList(checkbox, darkStateList);



                                                                    P.S. In addition if someone is interested, here is how you can get your checkbox from MaterialDialog dialog (if you set it with .checkBoxPromptRes(...)):



                                                                    CheckBox checkbox = (CheckBox) dialog.getView().findViewById(R.id.md_promptCheckbox);


                                                                    Hope this helps.







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Oct 22 '18 at 12:02









                                                                    Kirill KarmazinKirill Karmazin

                                                                    1,2471112




                                                                    1,2471112






























                                                                        draft saved

                                                                        draft discarded




















































                                                                        Thanks for contributing an answer to Stack Overflow!


                                                                        • Please be sure to answer the question. Provide details and share your research!

                                                                        But avoid



                                                                        • Asking for help, clarification, or responding to other answers.

                                                                        • Making statements based on opinion; back them up with references or personal experience.


                                                                        To learn more, see our tips on writing great answers.




                                                                        draft saved


                                                                        draft discarded














                                                                        StackExchange.ready(
                                                                        function () {
                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5854047%2fhow-to-change-the-color-of-a-checkbox%23new-answer', 'question_page');
                                                                        }
                                                                        );

                                                                        Post as a guest















                                                                        Required, but never shown





















































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown

































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown







                                                                        Popular posts from this blog

                                                                        Florida Star v. B. J. F.

                                                                        Danny Elfman

                                                                        Lugert, Oklahoma