Hide the ActionBar

Sometimes you just want a “blank” screen for an Activity, such as a Help Page or web page (WebView). To remove the “distraction” of the top ActionBar (and give you a little more room on the screen) edit the /values/themes.xml file. For a specific Activity (or multiple Activities) create a new style block under the default style. Here’s an example that hides both ActionBar and Title:

<style name="Theme.NoActionBar" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>

Per the above XML code you give the style a custom Name (theme.NoActionBar), refer to its Parent (the default style for your App), set the windowActionBar attribute to false to hide it, and (optionally) set windowNoTitle to true to hide it too.

To activate this new style for a specific Activity edit your /manifests/AndroidManifest.xml file. Scroll down to the block containing the name of the desired Activity and insert the following bolded line containing your new style. Finally, select File/Sync Project to ensure all code changes are executed.

<activity android:name=".HelpAboutActivity"
            android:label="About and Help" />
Appearance of a Standard ActionBar
The ActionBar and Title are Hidden

By RicksIslander

Old school programmer (started way back with FORTRAN - on punch cards!). Most of my prior coding has been Web and Windows-based (Javascript, C#, ASP.Net). Java and the Android O/S are totally new to me, so I'm a beginner here too. Let's explore this stuff together.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.