Search code examples
androidandroid-actionbarandroid-themeandroid-datepicker

Adding Action bar to Default Theme


I am trying to add an action bar to my application. Below is a screen shot of my current application UI.

enter image description here

I am using a default theme so the action bar won't get displayed. So i am using a theme with action bar. When i use the theme, my UI gets messed up. The date picker changes its style. Below is an example, how the action bar is displayed.

enter image description here

Below is the xml code which contains action bar items.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@+id/action_search"

    android:title="Search"
    android:showAsAction="always|withText"/>


<!-- Refresh -->
<item android:id="@+id/action_refresh"

    android:title="Refresh"
    android:showAsAction="ifRoom" />

<!-- Help -->
<item android:id="@+id/action_help"

    android:title="Help"
    android:showAsAction="never"/>

<!-- Check for updates -->
<item android:id="@+id/action_check_updates"

    android:title="Check for Updates"
    android:showAsAction="never" />
</menu>

Below is the theme am using in the application make the action bar visible.

  android:theme="@android:style/Theme.Holo.Light.DarkActionBar"

Is there anyway to add the action bar to my default theme?

Thank you.


Solution

  • This is because you are using Theme.Holo.Light, this is giving you a light background. You can try @android:style/Theme.Material, as seen [here(https://developer.android.com/training/material/theme.html), but that requires Api 21. Otherwise you can try:

    <style name="CustomDarkTheme" parent="@android:style/Theme.Holo">
        <item name="android:actionBarStyle">@android:style/Widget.Holo.ActionBar.Solid</item>
    </style>