Icon Color - Android Toolbar

Asked

Viewed 907 times

4

How do I make the icon color, in API’s smaller than 21, also white? Na 21 works ok, but below as for example the 16, turns black.

I did it that way:

Toolbar

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

Style

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>


<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

1 answer

7


I decided by following what it says in these two links below:

I added the following information in the build.Radle:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId ""
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        // Stops the Gradle plugin’s automatic rasterization of vectors
        **generatedDensities = []**
    }
    // Flag to tell aapt to keep the attribute ids around
    aaptOptions {
        **additionalParameters "--no-version-vectors"**
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

I am using the version of Appcompat v23.2.0, so to allow vector drawables I used the settings above marked with ** in the file Gradle and solved.

For those using Gradle 2.0+, this involves adding the line vectorDrawables.useSupportLibrary = true in your Defaultconfig in the build.Gradle file.

  • Thanks for the code worked perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.