Why is AppTheme.NoActionBar not working?
Solution 1
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>
Solution 2
None of the other answers worked for me, but I found this solution:
Open values/styles.xml
in Android Studio and change this:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
to:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- changed .DarkActionBar to .NoActionBar -->
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Solution 3
If you just let Android Studio auto generate the activity, look in activity_welcome
. There is be android.support.design.widget.AppBarLayout
and if you delete it, the ActionBar should be gone.
Solution 4
You might have an action bar in your layout, or set theme in AndroidManifest file
Solution 5
Once WelcomeActivity extends AppCompatActivity, try Theme.AppCompat.NoActionBar:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
If not already done, include a version of appcompat library to your build.gradle:
dependencies {
compile 'com.android.support:appcompat-v7:24.1.1'
}
Related videos on Youtube
Can Poyrazoğlu
Has most experience in iOS programming and UI design. Loves astrophotography, board sports, feeding street animals, authoring his humble blog, and flying drones.
Updated on July 09, 2022Comments
-
Can Poyrazoğlu almost 2 years
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:
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); } }
-
IntelliJ Amiya about 8 yearsadd
<item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item>
-
-
wonsuc about 7 yearsYou saved me. Thanks.
-
LarsH almost 4 yearsCan you explain why the user's code didn't work as he expected?
-
Mehmet K almost 4 yearsAppTheme.NoActionBar already declares AppTheme as the parent theme. The period does that
-
Mehmet K about 3 yearsThe theme AppTheme.NoActionBar and the elements used in it are activity styling. Applying it to a FrameLayout inside an Activity does not affect the parent activity styling.
-
Android Dev about 2 yearsomgggg thank you!!!!!!! I have been searching EVERYWHERE