Layout shrinks content when showing Snackbar - android

I'm using a Unity/Vuforia view in an app, when showing a native Snackbar the whole content shrinks for a bit and stays that way.
My first thought was that it had something to do with the fact that unity/Vuforia sets the activity as 'Fullscreen', disabling that did not work as the issue still remains.
The Content before the snackbar has been shown
After the snackbar
I noticed it has the same height of a Toolbar or the NavigationBars at the bottom. When playing around with the options to hide the Navigation Bars I noticed the changes won't stay. When trying to hide it all, it hides for a second and then after a 200 milliseconds show again.
I tried it with this code
window.decorView.apply {
// 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.
systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}

The way I fixed it was by enabling the Fullscreen option in Vuforia, it was not what we desired, but it was the quickest solution.

Related

Completely Transparent Status Bar doesn't work on some devices

Hi I am trying to develop a page with completely transparent status bar and white Navigation bar. I am using
getWindow().getDecorView().setSystemUiVisibility( SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
In fragment.xml in parent layout I have used
android:fitsSystemWindows="true"
But it is not working on some devices. It is showing an overlay in status bar on some devices.Though, it is working fine on some devices. Please help me out this.
I have also tried setting Full screen flag but it causes my status bar font to disappear.
I have also used statusBarUtil library but it causes navigation bar to turn black.
Try this to hide the ActionBar:
getSupportActionBar().hide();
using immersive mode
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
more information check it out:
https://developer.android.com/training/system-ui/immersive

When Android automatically exits Immersive Sticky it does not resize views so they are blocked

I have an activity which can go to Immersive Sticky Full Screen on the click of the button. This button does the following code in order to get into Immersive Sticky Full Screen.
getActivity().getWindow().getDecorView().setSystemUiVisibility(
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);
Note: I specifically do NOT include the following tag as if I do, it breaks the layout of my screen when I exit Immersive Sticky Full Screen.See my other question: Android closing full screen view at the bottom is shunted off the screen
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
When Android is in Immersive Sticky Full Screen when another view is displayed, such as a DialogFragment, a AlertDialog, keyboard comes up, Android automatically takes you out of Immersive Sticky Full Screen by showing the Status Bar and on screen navigation bar. However it does NOT resize the views in my application, so now my views are underneath the navigation bar and I can not get to any of the buttons at the bottom of my screen. I have tested with the "View.SYSTEM_UI_FLAG_LAYOUT_STABLE" flag and it makes no difference, the views are still not resized.
This seems a massive flaw in Android's behavior and surely I am doing something wrong. How can I get it to resize my views when it displays the status bar and Navigation bar?
I can work around some cases, such as Dialogs popping up by using the code in the following SO question, https://stackoverflow.com/a/24549869/2663916 but I have lots of possible things that could popup on my full screen view and I don't want to have to put that hack in every single place to keep it in immersive full screen. Furthermore, when the keyboard comes up I DO want the navigation bar to appear.
Surely Android should adjust the on screen views when it is displaying the on screen bars.
Re-reading Google docs made it obvious that the cause was the inclusion of the following two flags
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // this STOPS Android resizing my view to be below the status bar when it is displayed
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // this STOPS Android resizing my view to be above the nav bar when it is displayed
https://developer.android.com/training/system-ui/immersive.html
"It's good practice to include other system UI flags (such as SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION and SYSTEM_UI_FLAG_LAYOUT_STABLE) to keep the content from resizing when the system bars hide and show. You should also make sure that the action bar and other UI controls are hidden at the same time. "

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.

How to put a View in the back of the Navigation Bar in Android?

I have one View which I want to put in the whole screen, ie.. by making the status bar (top bar) and navigation bar (bottom bar) translusent and putting some portion of the view behind it. I tried the using the flags :
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
But they just hide them, and on touching these flags get cleared. It is understandable that android OS wants user to always have the navigation bar and that is why it is showing them again, but isn't there a way to just show our view behind the navigation bar.
I manage to put my layout behind the status bar using
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
But still, how can I put my view behind Navigation bar too.
Also I am developing the app for API level 14 and above, so I cant use, IMMERSIVE_STICKY or IMMERSIVE mode. Any Suggestions will be appreciated.

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