user1006072 user1006072 - 1 year ago 103
Android Question

Android appcompat theme always shows black color actionbar

I generated actionbar style using this web based tool which is very common

I've 'android-support-v7-appcompat' as an individual project in my workspace. I dumped all the contents of the res folder generated by downloading the zip file from this tool into this project.

I used a dark blue kinda color for the action bar and context menu (pop up).
However, I'm not able to achieve the custom look from this theme. Most of the elements / components show a default look.
The actionbar is black (instead of blue) and the pop menu is grey (instead of light blue)

My style.xml from the value folder

<style name="Theme.dinemobileandro" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_dinemobileandro</item>
<item name="popupMenuStyle">@style/PopupMenu.dinemobileandro</item>
<item name="dropDownListViewStyle">@style/DropDownListView.dinemobileandro</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.dinemobileandro</item>
<item name="actionDropDownStyle">@style/DropDownNav.dinemobileandro</item>
<item name="actionBarStyle">@style/ActionBar.Solid.dinemobileandro</item>
<item name="actionModeBackground">@drawable/cab_background_top_dinemobileandro</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_dinemobileandro</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.dinemobileandro</item>

<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">@style/Theme.dinemobileandro.Widget</item>


I've made the necessary changes in my manifest file as well

android:theme="@style/Theme.dinemobileandro" >

I've followed the steps mentioned in this blog closely and it worked for me previously for a sherlock theme.
However, this time, I migrated to appcompat and it stopped working. I've searched through SO and Google a lot and tried a couple of things suggested but all in vain.

Please help. Thanks in advance.

Answer Source

With AppCompat v21 the actionbarstylegenerator is deprecated.

Now it is very simple to customize the ActionBar (or better the Toolbar). Just use something like this:

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- Set AppCompat's color theming attrs -->
    <item name="colorPrimary">@color/my_color</item>
    <item name="colorPrimaryDark">@color/my_darkercolor</item>


You can find more info in the official blog:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download