为什么AppTheme.NoActionBar无法正常工作? [英] Why is AppTheme.NoActionBar not working?

查看:837
本文介绍了为什么AppTheme.NoActionBar无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Android Studio中创建了一个Android应用,并且默认情况下它创建了以下样式:

I've created an Android app in Android Studio, and it has created these styles by default:

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

但是,在一个活动中,我尝试将其设置为主题:

However, in an activity, I try to set this as a theme:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
   ...
android:theme="@style/AppTheme.NoActionBar">

但是当我运行该应用程序时,我会看到操作栏:

But when I run the app I'm getting the action bar:

我为什么要获得操作栏?我是不是做错了明显的事情,还是Google Studio本身的平台的官方IDE Android Studio试图混淆/误导其开发人员?

Why am I getting an action bar? Am I doing something obviously wrong, or is Android Studio, Google's official IDE for it's own platform, trying to confuse/mislead its developers?

这是我的活动代码,其中没有任何内容可以导致操作栏单独显示:

Here is my activity code, there's nothing in it that can cause the action bar to appear by itself:

public class WelcomeActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.activity_welcome);
    }
}

推荐答案

尝试如下操作:

<style name="AppTheme.NoActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
  </style>

,并将其设置为清单中活动的主题,即:

and set this as the theme of your activity in the manifest, that is:

<activity
    ...
    android:theme="@style/AppTheme.NoActionBar">
</activity>

这篇关于为什么AppTheme.NoActionBar无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆