Why is AppTheme.NoActionBar not working?

Can Poyrazoğlu picture Can Poyrazoğlu · Apr 7, 2016 · Viewed 70.9k times · Source

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:

enter image description here

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);
    }
}

Answer

Mehmet K picture Mehmet K · Apr 7, 2016

Try something like this:

<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>