为什么 AppTheme.NoActionBar 不起作用? [英] Why is AppTheme.NoActionBar not working?
问题描述
我已经在 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:
为什么我会得到一个操作栏?是我做错了什么,还是 Android Studio(Google 为其自己平台的官方 IDE)试图混淆/误导其开发人员?
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屋!