Carlos Paulino
Carlos Paulino

Reputation: 796

Keeping the Holo Action Bar in Lollipop

Is there any way to force an app to display the Holo Action Bar in Lollipop devices?

My theme is currently inheriting from Holo.Light, yet I am seeing the new Action Bar. The Youtube app does this but I believe that it is using an older version of the AppCompat library.

Any suggestions ?

Upvotes: 3

Views: 4151

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006664

Is there any way to force an app to display the Holo Action Bar in Lollipop devices?

Use Theme.Holo or one of its subsidiary themes, directly or as an inherited theme.

My theme is currently inheriting from Holo.Light, yet I am seeing the new Action Bar

First, here is a sample project that uses Theme.Holo.Light.DarkActionBar directly in its manifest:

<application
    android:allowBackup="false"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
    android:uiOptions="splitActionBarWhenNarrow">

The results when run on a Nexus 4 running Android 5.0 show the Holo-style action bar, even showing the now-deprecated split action bar pattern:

ShareNative sample app, as initially run

Here is a sample app that refers to a custom theme:

<application
    android:allowBackup="false"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Apptheme">

where that custom theme inherits from Theme.Holo and modifies the action bar, courtesy of Jeff Gilfelt's Action Bar Style Generator:

<style name="Theme.Apptheme" parent="@android:style/Theme.Holo">
    <item name="android:actionBarItemBackground">@drawable/selectable_background_apptheme</item>
    <item name="android:popupMenuStyle">@style/PopupMenu.Apptheme</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.Apptheme</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Apptheme</item>
    <item name="android:actionDropDownStyle">@style/DropDownNav.Apptheme</item>
    <item name="android:actionBarStyle">@style/ActionBar.Solid.Apptheme</item>
    <item name="android:actionModeBackground">@drawable/cab_background_top_apptheme</item>
    <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_apptheme</item>
    <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Apptheme</item>
</style>

The results when run on a Nexus 4 running Android 5.0 show the styled action bar:

HoloColor demo, as initially run

If you can offer a reproducible test case that demonstrates a Theme.Holo-based app offering a Material-ish look (which is my interpretation of "the new Action Bar"), please upload it somewhere.

Upvotes: 2

Related Questions