I have an issue with Android Navigation Bar on devices like Nexus etc. Simply at all devices, which do not have the hardware menu button.
Let me explain the issue in more details.
I have an application where there are 3 parts. Content, ActionBar and bottom panel with a SeekBar.
ActionBar and bottom panel with a SeekBar are overlaying the content. Everytime I click on the content the ActionBar and bottom panel with a SeekBar disappear. Which works exactly the way it has to work. Here is a fragment of a code I use for hiding system UI:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
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);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
actionBar.hide();
}
findViewById(R.id.read_book_bottom_bar).setVisibility(View.GONE);
In onCreate method of my activity, I have this piece of code:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN);
}
However, when I launch the application on devices with Android Navigation Bar, there is a problem with displaying the bottom panel with a SeekBar. Simply, the Android Navigation Bar overlays the bottom panel with a SeekBar. Here is a screenshot:
But everytime I click on the content, the Android Navigation Bar disappears along with the ActionBar and the bottom panel with the SeekBar. So, the issue is, that everytime somebody would like to use the bottom panel with the SeekBar on devices like NEXUS, he/she would not be able to use it, because it's hidden under the Android Navigation Bar.
Could anybody help me with solving this issue? Thank you all in advance.
Finally, I solved it with attribute fitsSystemWindows = true.
That may also happen when you set android:layout_gravity="center" and android:layout_marginTop="30dp"
I fixed similar issue by seting android:layout_gravity="center_horizontal" instead. Then marginTop works as assumed.
Related
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
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.
I have AppcompatActivity (appcompat-v7:25.3.1) which is in full screen mode using the below code. But the problem is that when in full screen mode and navigationview is displayed it shows these black overlay bar on top and bottom of it in Android 6.0, equal to the sizes of status bar and navigation bar.
Navigation view after applying the below mentioned flags (Can't embed images for now :( )
private void hideAndroidNavigation() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
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);
}
In Android 4.4 however the black overlay simply turns to white
as you can see in this image.
I was able to remove the overlay for the status bar using following code:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
But I have no luck for the removal of the navigation bar overlay. I tried this solution https://stackoverflow.com/a/38008965/4428159, suggesting to remove View.SYSTEM_UI_FLAG_LAYOUT_STABLE but still the output was same
Is there any other way to remove these overlays or a solution specific to appcompat libraries?
Check if you have the following line fitSystemWindows=true in your layout xml and style xml, if so remove the line or set the value to false
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.
There are some Android 4.4 applications in which the system's navigation bar is simultaneously dimmed and transparent. One example of this is the camera app on the Xperia Z1:
I've been trying to find a way to replicate this, and so far I have no problem setting up the navigation bar as translucent (by setting the style to android:Theme.Holo.NoActionBar.TranslucentDecor, for instance) or as dimmed:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE | decorView.getSystemUiVisibility();
decorView.setSystemUiVisibility(uiOptions);
The thing is, I can't seem to find a way to do both of them at the same time (i.e. simultaneously dimmed and transparent). It seems that whenever I define the app's style to use the transparent navigation bar, the dim flag stops having any effect.
I've tried a lot of different stuff with no results... Any suggestion? Thanks in advance for any answer.