Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Mohammed Safiulla D
Mohammed Safiulla D
17,044 Points

Is there is any way to set the checkboxes to different colors in Options Menu?

This question is regarding Create an Options Menu Workshop. As all the checkboxes are in Pink color, I was wondering if there is any way for the menu items (with checkboxes) to have different colors; so that red checkbox can be in red color and the same for blue and green?

1 Answer

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

I think you can do that using XML

<android.support.v7.widget.AppCompatCheckBox 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:buttonTint="@color/COLOR_HERE" />```
Mohammed Safiulla D
Mohammed Safiulla D
17,044 Points

Thank you for your answer this works in layout file but I can't apply this to a menuItem, I want to have the checkboxes in the Options Menu in different colors. so I tried adding buttonTint but it didn't work:

<item
            android:id="@+id/redItem"
            android:checkable="true"
            android:title="Red"
            app:buttonTint="@android:color/holo_red_dark"
            app:showAsAction="collapseActionView" />

        <item
            android:id="@+id/blueItem"
            android:checkable="true"
            android:title="Blue"
            app:buttonTint="@android:color/holo_blue_dark"
            app:showAsAction="collapseActionView" />
        <item
            android:id="@+id/greenItem"
            android:checkable="true"
            android:title="Green"
            app:buttonTint="@android:color/holo_green_dark"
            app:showAsAction="collapseActionView" />