I have a strange black bar (around 30 dp), which is over the navigation bar (see attached image).
It is preventing my app from fully wrapping it's view. Probably it is some system window border, which I can't yet find how to disable/resize.
It is observed in some apps, and in some it is not (which seems that applying some theme or window flag should remove it).
Here is what I've tried up to now:
Changed app theme to a different one (e.g. #android:style/Theme.DeviceDefault.Settings).
Applied this in oncreate:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
Changed the nav bar size - it only gets smaller, but the black line stays in the same position
Using uiautomatorviewer doesn't seem to show the view (and id) of the navigation bar at all.
Any help for removing this line would be appreciated.
Hello again and thanks for the support.
Finally I've found the issue. It was due to the api which was used (android-23). After updating to android-29, the issue is resolved. Seems that somehow theming or windowing mechanism is affected by the old api (and the app does not cover the whole screen - the rest is covered by a black background).
PS: I needed to restart the phone in order this to be applied. Killing of the app after adb push didn't apply the setting.
Related
The image below is basically my goal, a completely transparent navigation bar (NOT TRANSLUCENT) and the content behind it keeps getting inset updates so it draws behind it, but does not get any UI covered by the navigation controls.
So far the only way possible to achieve the result in the image above is to set the flag FLAG_LAYOUT_NO_LIMITS to the activity. The problem is when that is done, the app no longer receives any insets whatsoever, with the exception of Gesture insets, if gesture navigation is enabled.
I've tried all the combinations I could think of, but so far I am completely unable to achieve 100% transparent navigation bar + window insets.
I assume that the reason why the navigation bar is not translucent when setting that flag is because the system window insets are now 0, as such the translucent area shrinks to 0 height, leaving the navigation controls without background.
I also tried setting
<item name="android:navigationBarColor">#android:color/transparent</item>
However, all this does is leave the navigation bar fully white and the content does not display behind it.
And I also had the following enabled and disabled for all the tests I conducted
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
I've researched high and above the Window Insets nightmare and there's one way to find the window insets via getWindow().getDecorView().getRootWindowInsets(), but then I will be falling to the problem of adding insets when they aren't needed (multi-window mode, for example) and I still won't get window inset updates, such as when the keyboard is opened.
I've watched ( #chris-banes ) Chris Banes' "Becoming a master window fitter", however this specific scenario is never covered.
Is this impossible? We can achieve this result for the status bar, but we will never be able to do the same for the navigation bar? If not, then how can this be achieved?
All I want is a 100% transparent (NOT TRANSLUCENT) navigation bar and the app keeps receiving the window insets with the expected values instead of 0 for all the values.
Chris Banes also has a more recent blog post, going through exactly what you are asking for:
https://medium.com/androiddevelopers/windowinsets-listeners-to-layouts-8f9ccc8fa4d1
In short, set the following system ui flags on the root view:
rootView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
To get the following result:
Then you can update the padding or margin of your view to make it available for touch events by adding an onApplyWindowInsetsListener:
bottomNav.setOnApplyWindowInsetsListener { view, insets ->
view.updatePadding(bottom = insets.systemWindowInsetBottom)
insets
}
For the full solution, I suggest you read the whole post, it's a good read and has helped me a lot.
Problem
Activating and Deactivating (immersive) full-screen mode causes that the statusbar but also navigation bar "fades" in and out. The animation seem to differ across different devices and I would like to disable the animation completely. My minimum target SDK is 19; however, I would also be happy with a solution that requires a higher API level. Please see below for further details.
Running demo
I implemented a (minimal) demo so that people can test things easily. Everything is available on GitHub:
https://github.com/sztyler/android-fullscreendemo
For clarification, I am using setSystemUiVisibility(FLAGS) to activate/deactivate the full screen mode. Further, I am using the following flags:
Activating full-screen mode:
int visibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
mainView.setSystemUiVisibility(visibility);
Deactivating full-screen mode:
int visibility = View.SYSTEM_UI_FLAG_VISIBLE;
mainView.setSystemUiVisibility(visibility);
What I tried
I already tried many different things and did a lot of research. In the following, I want summaries the main approaches which I already tried.
Instead of using setSystemUiVisibility (which seems to be recommended) a lot of people recommend to use getWindow().setFlags to change flags. However, setting the Flags in a different way does not seem to have an effect. I also assume that this is outdated.
how to remove statusbar animation when changing to fullscreen in Android
Hide and show statusBar with Toolbar at the same time in android
Android: Disable and enable to pulling the status bar programmatically for API 19
hide and show statusbar without any effect to layout in android
Android: show/hide status bar/power bar
It seems to be possible to exclude the status bar and navigation bar from the exit/enter fade transition when switching between activities. However, this does not seem to have any effect on activating/deactivating full-screen mode.
How do I prevent the status bar and navigation bar from animating during an activity scene animation transition?
Some people just recommend different flags (just in general to hide the bars) -but the animation stays the same.
View.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
Android: Ability to Auto-Hide the Title/Status Bars?
Some people highlight that it is possible to override the subsequent animation with overridePendingTransition(0, 0)
but this does not seem so work in this case.
Is there any way to remove notification/status bar, but not in onCreate?
How the animation can look like
Just to clarify what I mean. In the following, there are gif animations which show the status/navigation bar animation (Sorry I don't have the permission to embed images)
Android 8.0 / Huawei / There is no fade out animation (both bars just vanish as required but there is a fade in animation). Both statusbar and navigationbar "flash in".
Statusbar Animation
Navigationbar Animation
Android 5.0 / Samsung / There is a fade in and fade out animation (There is no navigationbar).
Statusbar Animation
(The behavior of the actionbar is as expected.)
In React Native (With EXPO), I'm showing a Modal.
The Modal gets drawn behind the StatusBar in iOS but it's not happening on Android.
Do you know why? I could not find any solution for this.
The StatusBar has already set the translucent={true} prop. That's why you are able to see the Map behind the StatusBar on Android. But I can not draw the Modal component behind it (as I can do on iOS).
Here I add a couple of screenshots and an online viewer to check this behavior: https://snack.expo.io/BJR4oF4A7
Another weird behavior that I'm seeing is that it doesn't matter which translucent value I set, it always works in the same way (it's always translucent, even when I set it to false).
In case that this is impossible, how can I set the background to #FFF and the font-color to #000 on the StatusBar on Android?
I want to know:
Why there are different behaviors in iOS and Android.
Why changing the props of StatusBar still not changing its behavior (can be seen in the online viewer, changing translucent, or backgroundColor values)
If it's impossible to get the modal drawn behind the StatusBar, so, how can I change the background and the font-color of it when a Modal is opened? (in Android) (with no hiding it)
Android
iOS
I believe you need to try the app as a standalone application, not using the Expo client. It somehow sometimes has hard time dealing with StatusBar (I've already experienced it too).
You may use the hidden property that is working on both platforms, based on your current state: <StatusBar hidden={!!this.state.isModalShown} />
This will simply hide the status bar whenever your modal is opened.
Set the barStyle to be the contrasting backgroundColor.
Black writing on white background, so have dark-content on white status bar.
<StatusBar barStyle="dark-content" backgroundColor={"#fff"} />
This question has been asked several times -- and answered, but the answers don't seem to "add up".
Yes, one can simply set android:windowTranslucentStatus to true and set the WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS flag. (See Android Completely transparent Status Bar?) That produces a completely transparent status bar (in recent Android releases). That's great!
The issue is that this then results in the soft navigation bar being drawn over the lower contents (e.g. controls) within one's activity. I've tried resolving this with fitSystemWindows, but currently am clearly getting something wrong. Overall, it seems quite wrong that one has to get into any of this mess just to get a completely transparent vs. a translucent status bar!
I want to overlay a transparent view on the entire screen including the bottom most Navigation Bar in Android 4.4.
I am able to do so in Android 4.3 by defining the window Manager LayoutParams as TYPE_SYSTEM_OVERLAY, but when I use the same definition the layout is now pushed behind the navigation bar. could you please let me know if it due to the recent updates in KitKat? or If any one have a solution please share with me.
regards