Bar Action Bar is a standard Android interface element that displays the application name, navigation buttons and action menu. However, in some cases it may be redundant: when creating full-screen applications (games, media players), custom toolbars or minimalistic interfaces. You can remove it either programmatically through code or through theme settings in styles.xml.
In this article we will analyze all the current removal methods Action Bar for different versions of Android (from API 16 Jelly Bean to API 34 Android 14), including nuances for AppCompat i Material Components. We will pay special attention to common errors due to which the panel may remain visible even after applying styles.
1. Removing the Action Bar through the NoActionBar theme
The most reliable way to hide Action Bar is to use the built-in theme Theme.AppCompat.NoActionBar or its equivalent for Material Design. This method works at the style level and is guaranteed to remove the panel in all application activities.
Open the file res/values/styles.xml and replace the parent theme:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
- ๐ For Material Components use:
Theme.MaterialComponents.NoActionBar - ๐ If the panel is still displayed, check if the theme is not overridden in
AndroidManifest.xmlfor a specific activity - โก For Android 10+ add
android:windowFullscreen="true"to the style if you need to remove the status bar
After changing the styles, do not forget to apply the theme to the entire application in AndroidManifest.xml:
<applicationandroid:theme="@style/AppTheme"
... />
2. Programmatic hiding in activity code
If you need to dynamically hide Action Bar only in individual activities, use the hide or setVisible(false)methods. This approach is useful when the panel needs to appear/disappear based on a condition (for example, in full-screen video mode).
Add the following code to the method onCreate of your activity:
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// For AppCompatActivity
if (getSupportActionBar!= null) {
getSupportActionBar.hide;
}
// For regular Activity (deprecated, but works on API <21)
// ActionBar actionBar = getActionBar;
// if (actionBar!= null) actionBar.hide;
}
โ ๏ธ Attention: If you use Toolbar as a replacement Action Bar, callsetSupportActionBar(null)BEFORE callingsetContentView, otherwise it will occurNullPointerException.
To temporarily hide with the ability to return the panel back:
// HidegetSupportActionBar.hide;
// Show back
getSupportActionBar.show;
3. Removal via AndroidManifest.xml
A less known, but working way is to specify a theme without Action Bar in the manifest for a specific activity. This overrides the global styles of the application.
Add an attribute android:theme to the desired one <activity>:
<activityandroid:name=".MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- ๐ This method is useful if you need to hide the panel in only one activity, leaving it in the rest
- ๐ ๏ธ For Android 12+ check compatibility with Splash Screen API โsometimes the theme may conflict
- ๐ฑ On some devices Xiaomi i Huawei may require additional hiding via
WindowInsetsController
Make sure the panel is not being used for navigation|
Check compatibility with the minimum version of the API|
Save a backup copy of styles.xml|
Test on the emulator and a real device-->
4. Full screen mode with hiding the status bar
If your goal is to create a fully immersive interface (for example, for a game or media player), it is not enough to remove just Action Bar. You will need to hide both status barand the navigation bar.
Use the following code in onCreate:
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide the Action Bar
if (getSupportActionBar!= null) {
getSupportActionBar.hide;
}
// Remove the status bar and navigation panel
getWindow.getDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
}
| Flag | Effect | API level |
|---|---|---|
SYSTEM_UI_FLAG_FULLSCREEN |
Hide the status bar | 16+ |
SYSTEM_UI_FLAG_HIDE_NAVIGATION |
Hide the bottom navigation bar | 14+ |
SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
Full screen mode with temporary return of the panel when swiping | 19+ |
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
Stretches the content under the status bar (transparent status bar) | 16+ |
โ ๏ธ Attention: On devices with a notch or dynamic island (iPhone-style), additional settings may be required WindowInsets for correct display of content.
5. Problems and solutions: why the Action Bar does not disappear
Even after applying all the instructions Action Bar it may remain visible. Here are the most common reasons and their solutions:
- ๐ง Theme conflict: You may have a style override in
styles-v21.xmlorstyles-v31.xml. Check all files in the folderres/values*. - ๐ฑ Manufacturer modifications: On devices Samsung, Xiaomi or Oppo Sometimes you need to explicitly call
getWindow.setFlags. - ๐ Wrong order of calls: Make sure that
setContentViewis called after hide the panel, otherwise it may appear again. - ๐ ๏ธ AppCompat vs Native: If you use
getActionBarinstead ofgetSupportActionBarin AppCompatActivity, the panel will not hide.
For diagnostics, add to onCreate logging:
Log.d("ActionBarDebug","ActionBar is null:" + (getSupportActionBar == null));
Log.d("ActionBarDebug","ActionBar visibility:" + (getSupportActionBar!= null? getSupportActionBar.isShowing:"N/A"));
How to check the current activity theme programmatically?
Use the following code for debugging:
TypedValue value = new TypedValue;getTheme.resolveAttribute(android.R.attr.windowActionBar, value, true);
Log.d("ThemeDebug","ActionBar enabled:" + (value.data!= 0));
If the result is true, then the theme still contains an Action Bar.
6. Alternatives to Action Bar: Toolbar and Jetpack Compose
If you remove Action Bar, most likely you need a replacement. Modern approaches:
1. Toolbar (AppCompat):
<androidx.appcompat.widget.Toolbarandroid:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextColor="@android:color/white" />
In code:
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); // Now this is your custom Action Bar
2. Jetpack Compose:
// Instead of Action Bar, use TopAppBarScaffold(
topBar = {
TopAppBar(
title = { Text("My App") },
navigationIcon = {
IconButton(onClick = { / Handle back / }) {
Icon(Icons.Default.ArrowBack, null)
}
}
)
}
) { padding ->
// Content
}
3. Custom solutions: For games or non-standard interfaces, you can create your own panel with ConstraintLayout or MotionLayout, adding buttons and animations in your own way design.
If you use Navigation Component, do not forget to configure AppBarConfigurationso that the "Back" button works correctly with the navigation graph.
7. Features for different versions of Android
Behavior Action Bar may differ depending on the OS version:
| Android version | Features | Solution |
|---|---|---|
| Android 4.4 (KitKat) and below | No AppCompat, native is used ActionBar |
Use getActionBar.hide and theme Theme.Holo.NoActionBar |
| Android 5.0โ7.1 (LollipopโNougat) | Support Material Design, but there may be bugs with the panel shadow. mode | Add app:elevation="0dp" For Toolbar, if the shadow interferes |
| Android 8.0โ9.0 (OreoโPie) | Entered Picture-in-Picture mode that may conflict with full screen mode | Disable PiP for activation via android:supportsPictureInPicture="false" |
| Android 10+ | Gesture navigation has appeared that can overlap content | Use WindowInsetsController for correct processing of gestures |
โ ๏ธ Attention: Starting Since Android 12, Google has tightened the requirements for full-screen modes. If your application hides the system bars for longer than 5 seconds without user interaction, the system may show a warning about the "stuck" interface.
For maximum compatibility, always test removing Action Bar on emulators with API 16, 21, 28 and 33 - this will cover 99% of devices on the market.
FAQ: Frequently asked questions about removing the Action Bar
Is it possible to remove the Action Bar only in landscape orientation?
Yes, to do this, create a separate style file res/values-land/styles.xml and redefine the theme without Action Bar only for landscape mode. For example:
<style name="AppTheme.Landscape" parent="Theme.AppCompat.NoActionBar">
</style>
Then apply this theme in the manifest for the activity with the attribute android:screenOrientation="landscape".
Why is there empty space at the top after hiding the Action Bar?
This is due to reserving space for the status bar or Action Bar in the markup. Solutions:
- Add
android:fitsSystemWindows="true"to the rootViewGroup. - Use
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREENto stretch the content under the status bar. - For ConstraintLayout install top constraint to
parentinstead ofactionBar.
How to remove the Action Bar in a dialog box (DialogFragment)? summary>
For DialogFragment override the style in onCreateDialog:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes the title
dialog.getWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
return dialog;
}
Or use a theme Theme.AppCompat.Dialog.NoActionBar.
onCreateDialog:@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes the title
dialog.getWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
return dialog;
}
Theme.AppCompat.Dialog.NoActionBar.Does removing the Action Bar affect application performance?
No, Action Bar does not consume significant resources. However:
- If you replace it with a custom one Toolbar with heavy animation, this may affect FPS.
- On devices with Android Go (low-end) each pixel on the screen saves memory, so removing unnecessary interface elements justified.
Is it possible to return the Action Bar back after hiding?
Yes, if you hid it programmatically (hide), just call getSupportActionBar.show. If you used a theme NoActionBar, you will need to:
- Change the theme back to
Theme.AppCompat. - Recreate the activity (
recreate) or restart the application.