Search code examples
androidandroid-actionbarandroid-stylesandroid-actionbar-compat

Actionbar Styling: Transparent Background, Hidden Title Text, but Black Icons?


I want to style my ActionBar this way: Transparent background, hidden title text and having black icons (menu and back button). With "icons" I mean the three dots on the right or the back-arrow if you're not on your MainActivity-screen. This is my code:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="colorPrimary">@android:color/transparent</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:actionMenuTextColor">@android:color/black</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="android:displayOptions">showHome|useLogo</item>
    <item name="displayOptions">showHome|useLogo</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:actionMenuTextColor">@android:color/black</item>
    <item name="colorPrimary">@android:color/black</item>
    <item name="android:textColorPrimary">@android:color/black</item>
</style>

So both works transparent background and removing the title text, but I just want to add the black color to the icons. As you can see in the code I tried that but without success.

At the moment they are WHITE, so I can just barely see them. Note that this change (from black to white) happened right after I removed the title text.


Solution

  • You are using Theme.AppCompat.Light.DarkActionBar which will set icon color to white. Try use Theme.AppCompat.Light instead.