stricks
stricks

Reputation: 96

Appcompat toolbar's back button and option button are black

We're using the new toolbar instead of the old actionbar in our app.

Everything works as expected on Android 5 and higher. On Android 4 and lower, the back button and the option button are displayed in black

Android 4 and lower : the buttons are black

while they should be white

Android 5 and higher : the buttons are white

Our themes.xml is defind as follow :

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
    <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>

    <item name="colorPrimary">@color/ColorPrimary</item>
    <item name="colorPrimaryDark">@color/ColorPrimaryDarker</item>
    <item name="colorAccent">@color/ColorPrimaryRipple</item>
</style>

<!-- AppCompat Theme Transparent -->
<style name="Theme.Translucent" parent="AppTheme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@color/club_nestle_description_activity_background</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
</style>

The toolbar :

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/ColorPrimary"
    android:elevation="4dp"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

Any help would be appreciated !

Upvotes: 2

Views: 1012

Answers (3)

stricks
stricks

Reputation: 96

I found the solution : my gradle file was missing the following lines :

android {  
   defaultConfig {  
     generatedDensities = []  
  }  

  // This is handled for you by the 2.0+ Gradle Plugin  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
 } 

Upvotes: 2

Gueorgui Obregon
Gueorgui Obregon

Reputation: 5087

Try this. Create a custom theme for your Toolbar:

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

And apply like this

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/ColorPrimary"
    android:elevation="4dp"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/MyToolbarStyle" />

EDIT: If this dont work try changing tint color programmatically in your Activity:

final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);

Refer for more info to @Carles answer .

Hope its helps!

Upvotes: 1

T D Nguyen
T D Nguyen

Reputation: 7613

Try this to your AppTheme style:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

Upvotes: -1

Related Questions