Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android appcompat theme always shows black color actionbar

I generated actionbar style using this web based tool which is very common http://jgilfelt.github.io/android-actionbarstylegenerator/

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>

</style>

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

  <application
   android:name="com.railyatri.in.mobile.MainApplication"
   android:allowBackup="true"
   android:allowClearUserData="true"
   android:enabled="true"
   android:icon="@drawable/ic_launcher"
   android:label="@string/app_name"
   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. http://java.dzone.com/articles/creating-custom-android-styles 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.

like image 671
user1006072 Avatar asked Feb 20 '15 13:02

user1006072


1 Answers

With AppCompat v21 the actionbarstylegenerator is deprecated.

You can use something like this to customize the ActionBar (or better the Toolbar).

<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>
    
</style>

You can find more info in the official blog: http://android-developers.blogspot.it/2014/10/appcompat-v21-material-design-for-pre.html

like image 111
Gabriele Mariotti Avatar answered Nov 11 '22 09:11

Gabriele Mariotti