1

I use Toolbar and Menu in my class.

Here is the menu_main.xml:

<?xml version="1.0" encoding="utf-8"?> 

<group android:checkableBehavior="all"> <item android:id="@+id/menu_main_checkbox" android:title="checkbox" app:actionViewClass="android.support.v7.widget.AppCompatCheckBox" app:showAsAction="ifRoom" /> </group> <item android:id="@+id/menu_main_delete" android:title="@string/menu_main_delete" app:showAsAction="never" /> <item android:id="@+id/menu_main_rename" android:title="@string/menu_main_rename" app:showAsAction="never" /> <item android:id="@+id/menu_main_copy" android:title="@string/menu_main_copy" app:showAsAction="never" /> <item android:id="@+id/menu_main_new_folder" android:title="@string/menu_main_new_folder" app:showAsAction="never" /> 

And here is what it is now:

enter image description here enter image description here

How should i do to change the theme for checkbox in toolbar? I hope it can be white when checked.

2
  • are you doing any handling in Java when user presses the checkbox? If so, can you show the code here on what you do when AppCompatCheckBox is pressed? Commented Sep 19, 2016 at 2:48
  • No, i didn't do anything. Commented Sep 19, 2016 at 4:17

1 Answer 1

2

You can change checkbox color directly in the xml. Use buttonTint value 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 APIs:

<android.support.v7.widget.AppCompatCheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" app:buttonTint="@color/COLOR_HERE" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.