Ginsor Ginsor - 4 months ago 21
Android Question

Setting Overflow and popup colors in Toolbar

I can't find the reason why this part of my menu stays in that light background color and light textcolor. I tried a lot of different things in my styles xml but nothing had an effect on it.

Someone can help me?

<style name="MyTheme" 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>
<item name="android:windowContentOverlay">@null</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="android:windowBackground">@color/backgroundColor</item>
<item name="android:textColor">#FFFFFF</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/MyTitleTextStyle</item>
</style>

<style name="MyTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/ActionBarTextColor</item>
</style>


In my Manifest file i wrote under application:

android:theme="@style/MyTheme"

Answer

Add following color to your theme:

<item name="colorControlNormal">@color/colorPrimaryDark</item>

UPDATE

Since it does not work, let me share how I customized my Toolbar (Note that colors in the example below were created by me... So, you must change to the colors that your want.

Toolbar in Layout file

<android.support.v7.widget.Toolbar
    ...
    style="@style/ToolbarTheme"

    app:popupTheme="@style/ToolbarPopupTheme"
    app:titleTextAppearance="@style/ToolbarThemeTitleText" />

style.xml

<style name="ToolbarTheme" parent="Theme.AppCompat">
    <!-- Icon color -->
    <item name="colorControlNormal">@color/white_alpha_100</item>

    <!-- Background color -->
    <item name="android:background">@color/default_action_bar_color</item>
</style>

<style name="ToolbarThemeTitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">bold</item>
</style>

<style name="ToolbarPopupTheme">
    <!-- TEXT COLOR FOR POP UP MENU -->
    <item name="android:textColor">@color/black_alpha_100</item>
</style>
Comments