Button does not react to first tap in fullscreen mode - android

On the first start of my app I start an Intro-Activity in fullscreen with hidden navigation bar (black bar at the bottom) with:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
The Activity contains a Button to close it.
My problem is: with hidden navigation bar, the first tap on the close-button does not trigger the button, but reveals the navigation bar, only the second tap triggers the button.
Is there a way how I can close the Activity on first button tap?

The answer is described here- https://developer.android.com/training/system-ui/immersive.html. There's a new flag SYSTEM_UI_FLAG_IMMERSIVE that allows this. Unfortunately its KitKat and above only- older phones do not have the capability.

Related

How to remove back button from navigation bar?

I thought that is a solution for that but I cannot find it. I know that I can disable back button by overriding onBackPress() method and not call super.onBackPress() but it only disable, I want to remove/hide from navigation bar this button.
And I known that on some device where the back button is a part of hardware it can be done.
To be clear I mean arrow on below screen:
You can find solution in the documentation.
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
and this code should be placed in onCreate() method in the Activity after initializing all UI elements.
use this code in your onCreate() method : to hide
View bView = getWindow().getDecorView();
bView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

WebView: permanently disable status bar

I'm developing a one-view app which contains a fullscreen WebView. I started the project from a fullscreen template and added the code from both this and this official docs pages.
When the app is first started it works good and i obtain a fullscreen with no status bar. Problem is that when i exit the app (either opening the task manager or pressing the button that leads to the home) and then re-enter in it, the status bar is displayed and there's no way to hide it back if not closing and re-opening the app.
How can i fix this?
UPDATE
Here's the source code:
AndroidManifest.xml
FullscreenWebView.java
activity_fullscreen_web_view.xml
As already told, I haven't made much customization from the standard template of Android Studio.
The fullscreen code I've added is this, anyway:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
setContentView(R.layout.activity_fullscreen_web_view);

Force Android system ui to hide

I'm having trouble with Android's immersive sticky layout.
Under some circumstances, usual transparent status bar with home, back and multitask buttons becomes non-transparent visible, and even if I set right visibility flags back on, the non-transparent bar stays on screen.
Is there some programming way to force system UI to hide, and preferably to become transparent again?
I am using this method to hide the system UI in my app:
protected void hideSystemUI() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE;
decorView.setSystemUiVisibility(uiOptions);
}

Android hide action bar, status bar and navigation controls

I am trying to make an activity that is completely fullscreen in landscape, and have the status bar and navigation buttons visible in portrait.
I have to be able to do this programatically.
This is how I tried make the app go fullscreen.
private void hideNavigationAndStatusBars(){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // these work only on API 21 and above
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
The problems are the following :
On some devices, I get a blank portion on the top of the screen, that is equal to the height of the status bar, even though the status bar is not showing
On other devices, the activity fills the whole screen, but when I click anything, the status bar and navigation bar appear, they resize the layout and it looks very ugly
What I am trying to achieve:
The activity should fill the whole screen in landscape, positioned behind the status bar and navigation bar, if they appear
When the user clicks on the screen, he/she should interact with the screen. Instead the first click displays the status and navigation bars and the interaction is possible only after this
The status bar should only appear when the user drags from the top
to hide action bar call getActionBar().hide() method.
And to make activity full screen call
this method
requestFeature(Window.FeatureNo_Title)
Use immersive mode and system ui stable flag to achieve this. For more information please refer the document in developer site.

Hide Bottom Option Bar in Android

I want to hide Bottom Option Bar in Android. I don't know whether we call it Option Bar it or not.
Please check it out Image below : Tell me if we call it something else. It is in bottom.
Now, I want to hide it. How to do it ?
It's called navigation bar, the reason for it only having the options button is probably because your device has hardware buttons for home and back, that's why it looks like an options button only bar.
Refer to the docs for hiding it, although it will only work for versions supporting it.
For 4.0+
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

Categories

Resources