Android

Mohammed Safiulla D
Mohammed Safiulla D
12,493 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
Tonnie Fanadez
UX Design Techdegree Student 15,257 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
12,493 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" />