Search code examples
androidcolorsiconsandroid-toolbar

Overflow Toolbar Icon (Three dots) doens't change color (API 15)


I want to tint the icon white.

This is the toolbar:

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:theme="@style/Toolbar"
            app:popupTheme="@style/PopupToolbar"/>

And the styles:

 <style name="MyTheme" parent="carbon_Theme.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:colorBackground">@color/background</item>
    <item name="android:textColor">@color/texto</item>
    <item name="android:textColorPrimary">@color/white</item>

</style>

<style name="Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:background">@color/primary</item>
    <item name="android:textColorPrimary">@color/white</item>
</style>

The thing is, all attributes works excepts the #%&@! "three dots" color. In a API 23 device the icon is white. The problem only happens on a API 15 devices, where it's black. WHY.

P.S. I also tried to apply themes directly:

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

But still happens. API 23 white icon, API 15 black icon.


Solution

  • You may be running into an issue with drawables being auto-generated by Gradle. We had a similar issue but with the Up Navigation Arrow in a navigation tool bar.

    For Gradle 2.0:

     // Gradle Plugin 2.0+  
    android {  
      defaultConfig {  
         vectorDrawables.useSupportLibrary = true  
      }  
    } 
    

    For Gradle 1.5

    // Gradle Plugin 1.5  
    android {  
      defaultConfig {  
        generatedDensities = []  
      }  
    
      // This is handled for you by the 2.0+ Gradle Plugin  
      aaptOptions {  
        additionalParameters "--no-version-vectors"  
      }  
    }  
    

    The full article is here: http://android-developers.blogspot.com/2016/02/android-support-library-232.html

    Even if you're not specifically using the new Vector Drawables out of the Support Library, this still affected our project.