joshua majebi joshua majebi - 1 month ago 18
Android Question

Changing the foreground color of the toolbar of an android app from black to white

So i am trying to change the foreground i.e color of the text, icons, back navigation button all to white of my apps toolbar.

My colors file is like so.

<resources>
<color name="colorPrimary">#0277bd</color> blue
<color name="colorPrimaryDark">#01579b</color> dark blue
<color name="textColorPrimary">#FFFFFF</color> white
<color name="windowBackground">#e0e0e0</color> light grey
<color name="navigationBarColor">#000000</color> black
<color name="colorAccent">#26A69A</color> turquoise
<color name="twitter_btn_background">#4099FF</color> blue
</resources>


My style config is like so.

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="drawerArrowStyle">@style/DrawerIcon</item>

<item name="android:actionBarStyle">@style/MyActionBar</item>

<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>


But this gives a black foreground on the apps toolbar. Just wondering what theme i should use to give a white foreground.

Answer

You could simply apply a dark actionbar theme to your Toolbar.

For example:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/Theme.AppCompat.Light"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:background="@color/toolbar_background">
</android.support.v7.widget.Toolbar>