Android - 开发预览中未显示操作栏

Android - Actionbar not showing in the development preview

A​​ctionbar 未在开发预览中显示,但在 运行 应用程序后正常显示,最小 api 为 15,尝试从清单文件中删除它们,没有显示 actionbar ,并且不能再 运行 该应用程序了。

这是一个全新的项目(尝试删除它并重新创建它并创建其他几个不同的最小值 api,仍然没有在开发中显示)

我的主题是空白的,父级 "parent="Theme.AppCompat.Light.DarkActionBar"""

尝试使用全息灯主题,崩溃并出现错误 "java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity."

默认 activity 扩展 actionbaractivity 而不是 activity,现已修复。谢谢

如果您在谈论 android studio/eclipse 的预览屏幕,请注意您可以在预览顶部更改您的主题,您必须有一个带有 NoActionBar 的主题。

检查在 XML 预览屏幕的顶部选择了哪个 主题

即使您使用的是 Eclipse,它看起来也很相似。

您的应用程序正在显示 ActionBar,因为您的 AndroidManifest 有一个显示 ActionBar 的主题。

试试这个

values/themes.xml

<style name="Theme.Mytheme" parent="Theme.AppCompat.Light.NoActionBar">

 </style>

分配清单中的项目

<activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.Mytheme">
 </activity>

如果您看不到操作栏以及状态栏或按钮,可能是因为布局编辑器中的 "Show Layout Decorations" 选项已关闭。只需选中此选项,所有内容都会再次显示。根据 Android Studio 3.3: