保持霍洛操作栏的棒棒糖棒棒糖、操作

2023-09-07 12:12:13 作者:自认与酒同醉

有没有什么办法来强制应用程序,以显示河洛操作栏的棒棒糖设备?

我的主题是当前从Holo.Light继承,但我看到了新的操作栏。 YouTube应用程序做到这一点,但我相信,它使用的是AppCompat库的旧版本。

有什么建议?

解决方案   

有没有什么办法来强制应用程序,以显示河洛操作栏的棒棒糖设备?

使用 Theme.Holo 或其附属主题之一,​​直接或继承的主题。

  

我的主题是当前从Holo.Light继承,但我看到了新的操作栏

首先,下面是一个使用 Theme.Holo.Light.DarkActionBar 直接在其清单:

 <应用
    机器人:allowBackup =假
    机器人:图标=@可绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@安卓风格/ Theme.Holo.Light.DarkActionBar
    机器人:uiOptions =splitActionBarWhenNarrow>
 
10个生活常识,里面9个你都不知道

结果上的Nexus 4运行Android 5.0显示全息式操作栏,甚至显示了目前德precated拆分操作栏模式中运行时:

下面是一个示例应用引用自定义主题:

 <应用
    机器人:allowBackup =假
    机器人:图标=@可绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ Theme.Apptheme>
 

在这里的自定义主题,由 Theme.Holo 继承并修改操作栏,礼貌杰夫Gilfelt的的动作栏样式生成器:

 <样式名称=Theme.Apptheme父=@安卓风格/ Theme.Holo>
    <项目名称=机器人:actionBarItemBackground> @可绘制/ selectable_background_apptheme< /项目>
    <项目名称=机器人:popupMenuStyle> @风格/ PopupMenu.Apptheme< /项目>
    <项目名称=机器人:dropDownListViewStyle> @风格/ DropDownListView.Apptheme< /项目>
    <项目名称=机器人:actionBarTabStyle> @风格/ ActionBarTabStyle.Apptheme< /项目>
    <项目名称=机器人:actionDropDownStyle> @风格/ DropDownNav.Apptheme< /项目>
    <项目名称=机器人:actionBarStyle> @风格/ ActionBar.Solid.Apptheme< /项目>
    <项目名称=机器人:actionModeBackground> @可绘制/ cab_background_top_apptheme< /项目>
    <项目名称=机器人:actionModeSplitBackground> @可绘制/ cab_background_bottom_apptheme< /项目>
    <项目名称=机器人:actionModeCloseButtonStyle> @风格/ ActionButton.CloseMode.Apptheme< /项目>
< /风格>
 

结果上的Nexus 4上运行时,运行的Andr​​oid 5.0显示风格的动作栏:

如果您可以提供一个可重复的测试案例,演示了一个 Theme.Holo 为基础的应用程序提供了材料上下的样子(这是我的跨pretation新的操作栏),请上传它的地方。

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 ?

解决方案

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.

 
精彩推荐