0

I have tried for several days to fix a problem where multiple of my UI elements in my toolbar is the wrong color. If you take a look at the picture below you can see what I mean:

enter image description here

Elements that should be white are black and I just can't figure out how to fix this through my theme.

Here's my themes.xml (sry about the mess in there, but theming is really difficult):

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.GuidelinesCompat.Light.DarkToolbar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/colorBackground</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowActionModeOverlay">true</item>
    <item name="toolbarStyle">@style/AppTheme.NoActionBar.ToolbarStyle</item>
    <item name="actionModeStyle">@style/AppTheme.NoActionBar.ActionModeStyle</item>
    <item name="searchViewStyle">@style/AppTheme.NoActionBar.SearchViewStyle</item>
    <!--<item name="android:actionModeBackground">@color/bg_action_mode</item>-->
    <!--<item name="android:textColorSecondary">@color/white</item>-->

</style>

<style name="AppTheme.ActionBar">
    <item name="android:windowActionModeOverlay">true</item>
</style>

<!-- Base toolbar theme. -->
<style name="AppTheme.NoActionBar.ToolbarStyle" parent="Widget.GuidelinesCompat.Toolbar">
    <item name="titleTextAppearance">@style/AppTheme.NoActionBar.ToolbarTitleTextAppearance</item>
</style>

<style name="AppTheme.NoActionBar.ToolbarTitleTextAppearance" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title">
    <item name="android:textColor">@color/white</item>
    <item name="android:textColorSecondary">@color/white</item>
</style>

<!-- Base Action Mode styles -->
<style name="AppTheme.NoActionBar.ActionModeStyle" parent="Widget.GuidelinesCompat.ActionMode">
    <item name="background">@color/bg_action_mode</item>
    <!--<item name="android:actionModeBackground">@color/bg_action_mode</item>-->
    <!--<item name="android:actionOverflowButtonStyle">@style/ActionModeTitleTextStyle</item>-->
    <!--<item name="statusBarColor">@color/grey_100</item>-->
</style>

<style name="ActionModeTitleTextStyle" parent="Widget.GuidelinesCompat.ActionButton.Overflow">
    <item name="android:textColor">@color/white</item>
    <item name="android:textColorSecondary">@color/white</item>
</style>

<style name="AppTheme.NoActionBar.SearchViewStyle" parent="Widget.AppCompat.SearchView">
    <!-- Sets the search icon -->
    <item name="searchIcon">@drawable/ic_search_white_24dp</item>
    <!-- Gets rid of the "underline" in the text -->
    <!--<item name="queryBackground">@color/white</item>-->
    <!-- Gets rid of the search icon when the SearchView is expanded -->
    <!--<item name="searchHintIcon">@null</item>-->
    <!-- The hint text that appears when the user has not typed anything -->
    <!--<item name="queryHint">@string/menu_examination_search_hint</item>-->
    <item name="android:textAppearance">@style/SearchViewTextAppearance</item>
</style>

<style name="SearchViewTextAppearance">
    <item name="android:textColorHint">@color/white</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:textColorSecondary">@color/white</item>
</style>

<!-- Theme applied to LoginActivity and SignUpActivity -->
<style name="AppTheme.Login" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@color/colorPrimary</item>
    <item name="android:textColorHint">@color/iron</item>
    <item name="android:textColorPrimary">@color/white</item>
    <item name="colorControlNormal">@color/iron</item>
    <item name="colorControlActivated">@color/white</item>
    <item name="colorControlHighlight">@color/white</item>
    <item name="colorButtonNormal">@color/colorPrimaryDarker</item>
</style>

<style name="AppTheme.NavigationView">
    <item name="android:textColorSecondary">@color/colorTextSecondary</item>
</style>

<!-- Theme applied to Textview in LoginActivity and SignUpActivity -->
<style name="WhiteText" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/white</item>
</style>

<!-- Animations applied to dialog when entering or exiting -->
<style name="DialogAnimation">
    <item name="android:windowEnterAnimation">@anim/slide_up</item>
    <item name="android:windowExitAnimation">@anim/slide_down</item>
</style>

I've found out that if I set textColorSecondary in my AppTheme.NoActonBar all my controls are correctly coloured white, but this gives me trouble in all my dialogs, that now also have textColorSecondary set to white.

I hope someone out there can show me a solution, cause I'm out of ideas.

Community
  • 1
  • 1
Bohsen
  • 4,242
  • 4
  • 32
  • 58

1 Answers1

4

Try this here .

In your toolbar layout:

 <android.support.v7.widget.Toolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:minHeight="?attr/actionBarSize"
      app:theme="@style/ToolBarStyle"
      app:popupTheme="@style/ToolBarPopupStyle"
      android:background="@color/actionbar/>

In your styles:

 <!-- ToolBar -->
  <style name="ToolBarStyle" parent="Theme.AppCompat">
      <item name="android:textColorPrimary">@android:color/white</item>
      <item name="android:textColorSecondary">@android:color/white</item>
      <item name="actionMenuTextColor">@android:color/white</item>      
      <item name="actionOverflowButtonStyle">@style/ActionButtonOverflowStyle</item>
      <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
 </style>
Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51
White Druid
  • 295
  • 1
  • 12