Android Question Immersive Mode

RandomCoder

Well-Known Member
Licensed User
Longtime User
Forum experts, please advise...

I've been following @corwin42 guides on applying Material design (an excellent read, search the forum for "Material" and you'll see what I mean). I've now got my app displaying in FullScreen mode with my own ToolBar and soon to have modifiable Menu. But the NavigationBar (at the bottom of screen containing Back and Home button) is still on display. I believe to get rid of this I need to enter ImmersiveMode!

I've followed the advice to use JavaObject to set ImmersiveMode (Android 4.4) and this works but leaves a space where the navigation bar was. The advice to fix this is to use the IME Library to detect the screen change and re-size the panel.... Persist webview through orientation change

This is probably fine if just resizing one or two controls. But my activity contains the ToolBar and a Panel, I was planning to load the Panel with a Layout scaled correctly to the device in use and this may contain several Views all of which I guess would need to be rescaled/repositioned. Is this advice still the best way of achieving what I require or is it possible to set ImmersiveMode in a Custom theme? However all my attempts to modify the theme have failed to compile :(

I'm thinking that I'll just live with the NavigationBar being present but thought I'd ask you experts first in case I'm missing something?

Thanks in advance,
RandomCoder :D

PS Could someone please also explain why the Sticky Immersive value is 5894 in the B4A example and yet the Android docs states that it should be 4096?
(I tried 4096, it doesn't work!)
public static final int SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Added in API level 19
Flag for setSystemUiVisibility(int): View would like to remain interactive when hiding the status bar with SYSTEM_UI_FLAG_FULLSCREEN and/or hiding the navigation bar with SYSTEM_UI_FLAG_HIDE_NAVIGATION. Use this flag to create an immersive experience while also hiding the system bars. If this flag is not set,SYSTEM_UI_FLAG_HIDE_NAVIGATION will be force cleared by the system on any user interaction, and SYSTEM_UI_FLAG_FULLSCREEN will be force-cleared by the system if the user swipes from the top of the screen.

When system bars are hidden in immersive mode, they can be revealed temporarily with system gestures, such as swiping from the top of the screen. These transient system bars will overlay app’s content, may have some degree of transparency, and will automatically hide after a short timeout.

Since this flag is a modifier for SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION, it only has an effect when used in combination with one or both of those flags.



Constant Value: 4096 (0x00001000)
 
Last edited:

RandomCoder

Well-Known Member
Licensed User
Longtime User
The number is a combination of several flags: IMMERSIVE_STICKY, LAYOUT_FULLSCREEN, HIDE_NAVIGATION and others which I currently don't remember.

It is problematic to correctly handle the size change, especially if the layout is complicated.
Thank you @Erel for the explanation. I thought it might be some combination of values and had tried adding IMMERSIVE_STICKY and a FULLSCREEN value (I forget which one) together but this did not add up to 5894 and neither could I find a property with that constant value. That's why I asked the question.

Thank you for clarifying that it is a combination of values. Is there nothing that can be done using themes? I'd be happy to apply the immersive mode to the whole application if it's possible?
Does anyone know of another way? Failing that, I think I'll stick with the NavigationBar showing as I don't want to add something that is going to prove problematic.
I have enough problems without creating myself even more :p
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Sorry, I know this post is old but it seems proper to post it here anyway.

It is problematic to correctly handle the size change, especially if the layout is complicated.

This is a weird problem and rather frustrating.
When you say it is problematic, do you intend with B4A only or is this problem present also when developing in Android (with Android Studio/Eclipse)?
 
Upvote 0
Top