Android 图形布局在某些情况下显示默认操作栏

Android graphical layout has a default actionbar shown in some cases

在我的 android 应用程序的 xml 图形布局中,我的 android 工作室项目之一显示了一个操作栏,而其他项目则没有。出于好奇,我想知道这背后的原因。我没有看到布局和活动的主题有任何变化。

显示如下内容:

PS:虚线以上部分为actionbar。我想以某种方式删除它。在我的任何其他 Android Studio 项目中都没有。

尝试将此添加到您的 styles.xml

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

并将 AppTheme.NoAction 添加到清单

中的 activity