Keeping the Holo Action Bar in Lollipop

走远了吗. 提交于 2020-01-21 12:18:27

问题


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 ?


回答1:


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:

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:

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.



来源:https://stackoverflow.com/questions/27389689/keeping-the-holo-action-bar-in-lollipop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!