android: how to remove the back/home button in the action bar

how to add back button in android title bar
android action bar
android add button to action bar
android action bar example source code
custom action bar android
show navigation bar android
hide navigation bar android 9
android show navigation bar programmatically

I am having difficulties trying to remove the back/home button from the action bar.

 getActionBar().setDisplayShowHomeEnabled(false);   //disable back button
 getActionBar().setHomeButtonEnabled(false);

In a older android phone, the back button is removed with these two code lines. However with the nexus 4, the back button still appears but is just disabled. Also I am just adding a menu item on the right that behaves like the back/home button replacing the back/home button. What am I missing?

Use getActionBar().setDisplayHomeAsUpEnabled(false) to remove the home button from the action bar.

How to remove the default back button from Android activity , How do I permanently hide the navigation bar in Android activity? Enable or disable the "home" button in the corner of the action bar. abstract void: setIcon(Drawable icon) Set the icon to display in the 'home' section of the action bar. abstract void: setIcon(int resId)

If you're on API level 14 or above and are not using ActionbarSherlock, this code in onCreateOptionsMenu will disable the up button, remove the left caret, and remove the icon:

ActionBar actionBar = getActionBar();
if (actionBar != null) {
    actionBar.setHomeButtonEnabled(false); // disable the button
    actionBar.setDisplayHomeAsUpEnabled(false); // remove the left caret
    actionBar.setDisplayShowHomeEnabled(false); // remove the icon
}

source: https://stackoverflow.com/a/24967862/2887103

Hide the navigation bar, It will have a default back button at the upper left corner. How to So, let's remove it b. it's from supportActionBar rather than actionBar . Up button it not them same with back button. The screenshot is of an iPhone. Android does not run on such devices. Android has its own back button, always available for the user; you do not need to put one in the action bar. Many apps today (2014) put a back/up button in the actionbar (eg.

ElectronicGeeks answer is correct.

For API lower than 11, Use:

getSupportActionBar().setDisplayHomeAsUpEnabled(false);

How to add Android Back Button / Up Button in Activity ActionBar , When the user reopens the activity, onCreate() won't get called, so the system bars will remain visible. If you want system UI changes to persist as  I can hide the action bar in honeycomb using this code: getActionBar().hide(); But when the keyboard opens, and user copy-pastes anything, the action bar shows again.

To control the up affordance, use setDisplayHomeAsUpEnabled().

Using the Android Toolbar (ActionBar) - Tutorial, You would learn how to add the Android Up/Back button in the activity toolbar to navigate Duration: 2:34 Posted: Jun 25, 2019 // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE. // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE View decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_IMMERSIVE // Set the content to appear under the system bars so that the // content doesn't resize when the system bars

None of the suggested solutions works for me.

But this one does:

// Hide the back button
mActionBar.setHomeAsUpIndicator(null);

It is a kind of a hack (last resort solution), though, so showing the action bar again means setting its icon back again.

Modifying the Touch Key bar, It is possible to disable the toolbar via the used theme, but the default package com.vogella.android.actionbar.homebutton; import android.os. If you want to customize UI of your ActionBar, then you can use Toolbar as ActionBar. Here are the steps to do the same : Add below code as a child of AppBarLayout in your activity layout xml. Make your Toolbar as ActionBar by adding the below code in your Activity onCreate() method.

Customize the Navigation bar on your Galaxy phone, Tap Hide Home touch buttons to hide the Touch Keys on the apps you select. To access the Touch Key bar from those apps, swipe upward from the bottom of the​  You hide action bar by with different ways. 1.action bar hidden through the manifest xml file (non Java Programming), then the easy way is to add the following attribute in Activity tag:

Android Notes 24: How to add Back Button at Toolbar [UPDATED v2], The Navigation Bar is the menu that appears on the bottom of your screen - it's the However, it isn't set in stone; you can customize the layout and button order​, Add or remove apps and widgets on your Galaxy phone's Home screen S9, S9+, S8, S8+, S7, S7 Edge, S7 Active or select iPhone and Android devices. On Android 4.1 and higher, you can set your application's content to appear behind the navigation bar, so that the content doesn't resize as the navigation bar hides and shows. To do this, use SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION . You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.

Action Bar, If you want to change the back button icon, you need to change R.drawable. “icon​” part. Method 2 : Now let's look at the old action bar method :). Android ActionBar Menu. The simplest way to get toolbar icons and action overflow items into the action bar is by creating menu XML resource file found in res/menu folder. We can add menu items in the raw xml file present in the folder as follows:

Comments
  • as you can see I have already tried that and it does not work.
  • It's a different method than setDisplayShowHomeEnabled. Did you try the code I posted? The setDisplayShowHomeEnabled method disables or enables the up affordance. The setDisplayHomeAsUpEnabled method puts the home button in the up affordance.
  • thanks buddy sorry about that, obvious fustration here, and I will accept your answer when 5 minutes is up
  • Answer worked for me. Just that my requirement was to hide, so added the above code without actionBar.setHomeButtonEnabled(false). Since its hidden, there is no need of disabling it.
  • This makes home icon as up but doesn't change it's behavior(opens navigation drawer when clicked). Also after hardware back press it goes back to last screen but the home icon doesn't show up. I am setting setDisplayHomeAsUpEnabled() as false when back button is pressed.
  • What is the toggle object ?