简体   繁体   English

Android-如何使用默认Theme.Light显示操作栏

[英]Android - how to display the Action Bar using the default Theme.Light

I would like to use the default Android Theme.Light in one my activities. 我想在自己的活动中使用默认的Android Theme.Light。 However, when this particular theme is applied in my application Manifest file for the selected activity: 但是,当此特定主题应用到我的应用程序清单文件中以用于所选活动时:

android:theme="@android:style/Theme.Light">

it hides the activity Action Bar. 它隐藏了活动操作栏。

What needs to be done in java or xml code to preserve the Action Bar, using this particular Light scheme ? 使用此特定的Light方案,需要用Java或xml代码完成哪些操作才能保留操作栏?

As an alternative, I have used the following default scheme: 作为替代,我使用了以下默认方案:

android:theme="@android:style/Theme.DeviceDefault.Light">

That scheme does show the activity Action Bar correctly, however some of its objects are not displayed as preferred. 该方案确实正确显示了活动操作栏,但是其中某些对象未显示为首选。 In particular, my preference would be to display buttons and spinners as per Theme.Light, but preserve the other style formatting offered by the Theme.DeviceDefault.Light 特别是,我的偏好是按照Theme.Light显示按钮和微调框,但保留Theme.DeviceDefault.Light提供的其他样式格式。

I would greatly appreciate some tips on how to achieve the above scheme formatting preferences. 我将不胜感激有关如何实现上述方案格式首选项的一些技巧。 (I am using SDK = 16). (我正在使用SDK = 16)。

Why not use "android:style/Theme.Holo.Light" ? 为什么不使用“ android:style / Theme.Holo.Light”? is the same but has actionbar it was added in the newer apis 是相同的,但有动作栏,它已添加在较新的api中

I think you should use Holo.Ligt theme. 我认为您应该使用Holo.Ligt主题。 The old android Theme.Light is not even aware of action bar. 旧的Android Theme.Light甚至都不知道操作栏。

I have the same problem, I like Theme.light's controls, I resolved it like this: 我有同样的问题,我喜欢Theme.light的控件,我这样解决了它:

1) define "Theme.Light.ActionBar" in project's styles : 1)在项目样式中定义“ Theme.Light.ActionBar”:

 <style name="Theme.Light.ActionBar" parent="@android:style/Theme.Light">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">true</item>
</style>

2) in the manifest use it : 2)在清单中使用它:

<activity
            android:name="com.your.Activity"
           android:theme="@style/Theme.Light.ActionBar" >

I hope that may help 希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM