31

I am building custom image.I going through android source, i want to get rid off bottom softkey button bar in android, Can some one please direct me to source file to change ? enter image description here

Shri
  • 1,223
  • 5
  • 22
  • 31
  • 3
    @DjHacktoReborn How did you come to the conclusion that it's not possible? Several applications at least hide this bar at different times. – jwir3 Sep 22 '14 at 16:49

13 Answers13

32

To enable / disable them, as far as I know you simply have to edit the build.prop:

qemu.hw.mainkeys=0 (show on screen buttons)

or

qemu.hw.mainkeys=1 (disable on screen buttons)

If the line does not exist in your build.prop, add it at the bottom.

damian
  • 2,001
  • 20
  • 38
19

The easiest way to take a screen shot without the bottom navigation bar is to use an emulator (AVD) and edit its config file.

Go to .android/avd/virtual-device.avd

Then edit the config.ini:

hw.mainKeys=yes
hw.keyboard=yes

Both should be set to "yes"

In order to be able to see the bar again, set them back to "no".

Dimitar Darazhanski
  • 2,188
  • 20
  • 22
  • This works perfectly for taking promo pictures for the newer Android Studio emulators in combination with the status bar demo mode. The new emulators are not rooted, so you can't modify build.prop easily, but this is a very nice workaround. – Dima Mar 17 '17 at 18:19
  • Doesn't work for me, changing mainKeys to yes cause emulator hang at boot time. Changing back to no makes it boot again. Nexus 5X API 26 – thanhbinh84 Jun 23 '17 at 02:00
  • 2
    @thanhbinh84 got the same problem, but works well with Pixel API 23 – Luidgi Gromat Aug 17 '17 at 10:16
  • Working after close and open AVD again to get effect of this changes. – user9453341 Jun 09 '20 at 20:49
9
getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); 

use this code in onCreate. But this requires api lv over 19.

8

You cannot hide it permanently, however:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

this code hides the soft keys until the user interacts with your app. This is intentionally designed this way, just imagine, you don't provide any mean to exit from the current screen and hide theese keys, the user would be "trapped" in a one-way dead end.

You can find more here.

hundeva
  • 1,058
  • 14
  • 30
  • This is a temporary solution, but this is very useful solution for normal circumstances – Shri Sep 30 '13 at 09:43
  • Welp, I failed to notice you are building an image, and thought you need an in-app solution. So obviously, this isn't your exact use-case. :) – hundeva Sep 30 '13 at 11:56
  • Thanks, this has helped me take screenshots. To hide the bottom bar even after interacting with the app, I call this method in a loop that runs every second (again, just temporarily as I take screenshots). – VinceFior Mar 21 '16 at 23:48
6

In addition to Aykut Burak SAFAK's answer above, you can put his code in onWindowFocusChanged event to make sure that whenever the Activity gets focus (e.g. after unlocking) it retains fullscreen without soft keys state.

@Override
public void onWindowFocusChanged(boolean hasFocus){
    super.onWindowFocusChanged(hasFocus);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
Bö macht Blau
  • 12,820
  • 5
  • 40
  • 61
Aaditya Dengle
  • 136
  • 1
  • 8
3

With introduction of new SureLock for Samsung, Bottom Bar can be disabled or hidden without rooting of the device. All you have to do is to install SureLock Lockdown for Samsung and follow procedures mentioned in the following site,

http://www.42gears.com/blog/2013/07/disablehide-android-bottom-bar-without-rooting-samsung-galaxy-tablets/

Check out the following link.It may help you understanding it.

http://www.42gears.com/blog/2012/02/disable-bottom-bar-in-android-honeycomb-tablets-with-surelock/

Spring Breaker
  • 8,233
  • 3
  • 36
  • 60
3

for API 32 android studio emulator you can change "Gesture Navigation" to "3 Button Navigation" or "2 Button Navigation", because it's sometimes has problems with scrolling drawerLayout

Settings -> System -> Gestures -> System Navigation enter image description here

1

If you only want to make the navigation bar (the button bar) less distracting, try youractivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE)

Corona Luo
  • 731
  • 1
  • 5
  • 5
1

Just change hw.mainKeys to yes in config.ini file.

1- Open config.ini file (To find file in your system follow steps below).

enter image description here

2- Don't forget to restart your emulator.

Houssin Boulla
  • 2,687
  • 1
  • 16
  • 22
0

I think this is possible

To hide the softkey Try getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); but it is not working on tablet 4+.

RussVirtuoso
  • 900
  • 1
  • 9
  • 20
0

Yes you can by using this in your activity :

@Override
public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}
}
Thiago
  • 12,778
  • 14
  • 93
  • 110
0

Is there a way to stretch the controls to the bottom of the screen if I hide my navigation bar? I have an ImageView with the height set to match_parent but the absent navigation bar leaves a black rectangle.

David Kachlon
  • 201
  • 3
  • 14
0

For lvl 30

window.decorView.windowInsetsController?.hide(android.view.WindowInsets.Type.statusBars())

Below 30

window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN