How do I remove the navigation bar from my Android build? - android

Since the device I am developing has physical buttons, I do not want to see a navigation bar taking up my screen space. Rowboat-android on Beagleboneblack shows the navigation bar by default. Where do I turn it off?
EDIT: I am not developing applications. I am developing a Beaglebone based device. I want to remove the bar globally from the system. Somewhere there should be a code or setting in the Android source.

Found the answer at Building a wireless Android device using BeagleBone Black
Basically I edited device/ti/beagleboneblack/overlay/frameworks/base/core/res/res/values/config.xml file to set this entry:
<bool name="config_showNavigationBar">false</bool>

You should use IMMERSIVE flag like this:
private void hideSystemUI() {
mDecorView.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
For more info, I recommend you to take a look at here.

Related

Strange behavior of fullscreen mode on Android 7.0

I have an application which will show fullscreen without problem on Android 4-6. But once test on Android 7.0, although the navigation and status bar are hide, the navigation bar position seems still occupied by a white bar. My application cannot automatically resize to occupy that space.
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
I use the above code to do the fullscreen. Please advise. Thanks.

How to disable naviagation bar in Android LockScreen App like CM locker and OS8 lock screen

I tried setting systemUIView(View.GONE) and use Immersive Full-Screen Mode. But users can always get the naviagtion bar back by touching the bottom of the screen. The apps i mentioned above are able to hide it without root or setting default launcher.
Okay, I found a solution finally and here is how it's done:
Use SYSTEM_UI_FLAG_IMMERSIVE_STICKY to hide the navigation bar as follow, you may put the code inside onResume of your activity
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
Then, add a system error window using WindowManger and overlay it on top of everything
you can put this unescapable view anywhere you like, but if you want to do it while users locked the screen, add this flag:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
Et voilĂ 
Well I've never achieved this but it seems that you will need to set some other flags to get this kind of view :
When you use the SYSTEM_UI_FLAG_IMMERSIVE flag, it hides the system bars based on what other UI flags you have set (SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_FULLSCREEN, or both). When the user swipes inward in a system bars region, the system bars reappear and remain visible.
Here is a snippet that you can use to set these flags :
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
For more information go check Using Immersive Full-screen Mode from the android developer website.
Hope this help.

How can I create an app as full screen in all android devices and without additional tools like the Navigation bar in android

I use the android:Theme.Light.NoTitleBar.Fullscreen for setting the layout as the full screen and without a Title Bar. But now I have a problem. some android devices have the additional tools like the Navigation bar and when I run my app in the devices, because there are the additional tools like the Navigation bar in the android devices, as the result my app is not Full Screen really and I see the Navigation bar still. Are there a way to solve this problem? How Can I create my app as Full Screen in all version of the android (API 7 to higher) really?
You can force notification bar like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
But the Navigation Bar is not going to go... only on API lvl 19+ (4.4+) and it's called "Immersive mode". You can hide it and show it like this:
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
For more info, check the official documentation: https://developer.android.com/training/system-ui/immersive.html

Android kiosk mode app - running status bar

I've got a problem with status bar in kiosk mode App.
I want to know how to hide status bar and I know that is it possible to disable it permanently in 4.4.2 Kitkat? But I found nice app -KioWare.
There is cool mode when I grab status bar down, it is running back to the top very quickly. In 0.05 sec. I am not able to click anything. And this is what I'm looking for.
I can't buy this app because it's to expensive and I only need this magic trick with status bar. Anyone can help me ? It should be only few lines of code.
I wrote an article that covers this question, but specifically for Lollipop. I'm not sure if the immersive mode in Android 5 will also apply for 4.4.2, but it's something to try out maybe?
http://www.sureshjoshi.com/mobile/android-kiosk-mode-without-root/
#Override
protected void onResume() {
super.onResume();
hideSystemUI();
}
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

How to remove button bar at the bottom screen

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 ?
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.
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".
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.
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.
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);
}
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/
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
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)
Just change hw.mainKeys to yes in config.ini file.
1- Open config.ini file (To find file in your system follow steps below).
2- Don't forget to restart your emulator.
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+.
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);}
}
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.
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

Categories

Resources