Home > front end >  How to remove Header title in bottom nav bar - Android Studio
How to remove Header title in bottom nav bar - Android Studio

Time:11-07

My objective is removing the orange bar thar has the label "App name".

Currently I have a top_app_bar and bottom_nav_bar. As far as I know the orange bar is generated by the bottom nav bar.

App design

This is the bottom nav bar implementation in the activity_main.

Activity_main.xml bottom_nav_bar implementation

This is the top app bar implementation in the activity_main. enter image description here

CodePudding user response:

The top bar is called ActionBar. The ActionBar is a part of the default layout of the theme you are using.

Method 1:

You can hide the ActionBar by creating a NO ActionBar Style in the Style.xml and setting the class's style to that.

In Style.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Then In the Manifest set the theme for the class to this NoActionBar Style.

In AndroidManifest.xml

 <activity
            android:name=".MainActivity"
            android:theme="@style/AppTheme.NoActionBar" />

Method 2

Simply add a default NoActionBar Style in Manifest

<activity android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

Method 3

You can do it programmatically

Java

if (getSupportActionBar() != null) {
    getSupportActionBar().hide();
}

Kotlin

supportActionBar?.hide()
  • Related