How to hide the navigation bar in Android

I want to hide the navigation bar.

 for example: like in the game “Jelly Jump”.

i saw this sulotion: http://docs.coronalabs.com/daily/api/library/native/setProperty.html#androidSystemUiVisibility

but it dosent work at all. 

i tried it in 2 ways: native.setProperty(“androidSystemUIVisibility”, “immersiveSticky”)

or: native.setProperty(“androidSystemUIVisibility”, immersiveSticky)

but the 2 does not work for me. I did something wronge?

I use this short bit of script, try it and see if it does what you need:

-- Android Settings -- if ( system.getInfo("platformName") == "Android" ) then local androidVersion = string.sub( system.getInfo( "platformVersion" ), 1, 3) if( androidVersion and tonumber(androidVersion) \>= 4.4 ) then native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) --native.setProperty( "androidSystemUiVisibility", "lowProfile" ) elseif( androidVersion ) then native.setProperty( "androidSystemUiVisibility", "lowProfile" ) end end

Oh, and tell us specifically what devices and OS’s you’ve tried this on.

-Ed

I tried: native.setProperty(“androidSystemUIVisibility”, “immersiveSticky”)

and native.setProperty(“androidSystemUIVisibility”, immersiveSticky) on nexus 5, android 5.1

I will try your code now

Thanks

Ah, This could be a “Lollipop” compatibility issue.  If my code doesn’t help, we’ve got one of two possibilities:

  1. Lollipop doesn’t support it (be sure to try “lowProfile” too) properly.
  2. Corona is somehow not communicating this to Lollipop.

I’d file a bug, if still doesn’t work for you.

-Ed

PS Try the above with this too:

display.setStatusBar(display.HiddenStatusBar) -- Hide that pesky bar

your code is working!!! you are the first one that gives me solution thar working! you are very good.

but I have another question: now, after i useed your code I see that the game’s frame is a little bigger then the screen. (it was before also but I thought it was because of the nevigation bar. on galalxy s5/s4 it works good.

I am using this code for making the game’s frame fit for all screen sizes:

config.lua:

local aspectRatio = display.pixelHeight / display.pixelWidth

application =

{

content =

{

  width = aspectRatio > 1.5 and 1080 or math.ceil( 1920 / aspectRatio ),

      height = aspectRatio < 1.5 and 1920 or math.ceil( 1080 * aspectRatio ),

scale = “letterBox”,

fps = 60,

edit: it dosent good on nokia lumia to.

just a  little longer (the game is out  of the screen frame) 

Well … I  managed to offend one person today, so I hope this doesn’t offend you, but please read through this post and follow up on Brent’s suggestion and my last post about making a test bench and trying things.

If you do this, I think you’ll quickly understand how config.lua affects what you see on the screen and how you can best place items so they look good on multiple-resolutions.

This is one of those things you have to learn by doing.  Its hard for me (at least) to give a single answer because as I said in the other thread,

We all have different recipes that resonate with the way we work.

-Ed

ok thak you

One more thing.  I define these globals (some will say ‘evil’!) in all my apps:

\_G.w = display.contentWidth \_G.h = display.contentHeight \_G.centerX = display.contentCenterX \_G.centerY = display.contentCenterY \_G.fullw = display.actualContentWidth \_G.fullh = display.actualContentHeight \_G.unusedWidth = \_G.fullw - \_G.w \_G.unusedHeight = \_G.fullh - \_G.h \_G.deviceWidth = math.floor((fullw/display.contentScaleX) + 0.5) \_G.deviceHeight = math.floor((fullh/display.contentScaleY) + 0.5) \_G.left = 0 - unusedWidth/2 \_G.top = 0 - unusedHeight/2 \_G.right = w + unusedWidth/2 \_G.bottom = h + unusedHeight/2

These may help you.  Oh, and if you want to be ‘cleaner’ make a module to contain them.  I find a few globals are fine, but others will disagree.  I’m considering encapsulating this in a module in the future. 

As Corona has advanced, some of these have become redundant, but I keep them because I’m used to working with them.  

One final thing.  It occurs to me that you may need to ‘reclaim’ lost vertical space when you turn off the status bar and footer.  You get get the status bar height here:

display.statusBarHeight

thak you again

I have another question: I noticed that my game is a little bit low, exactly as the navigation bar height. so i thought I will check (in the code you gave me and put a flage=true if it hide the nevigation bar and then move it up exactly the height of the navigation bar. but how do I know the height of the navigation bar?

Or how I can make the screen stay and not move down after I hide the navigation bar?

That I don’t know, but I’m guessing it is close to or the same as the status bar.

Anyone?

I think it is because of  code for making the game’s frame fit for all screen sizes. Mabye it isnt good. you have a beter sollusion?

I use this short bit of script, try it and see if it does what you need:

-- Android Settings -- if ( system.getInfo("platformName") == "Android" ) then local androidVersion = string.sub( system.getInfo( "platformVersion" ), 1, 3) if( androidVersion and tonumber(androidVersion) \>= 4.4 ) then native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) --native.setProperty( "androidSystemUiVisibility", "lowProfile" ) elseif( androidVersion ) then native.setProperty( "androidSystemUiVisibility", "lowProfile" ) end end

Oh, and tell us specifically what devices and OS’s you’ve tried this on.

-Ed

I tried: native.setProperty(“androidSystemUIVisibility”, “immersiveSticky”)

and native.setProperty(“androidSystemUIVisibility”, immersiveSticky) on nexus 5, android 5.1

I will try your code now

Thanks

Ah, This could be a “Lollipop” compatibility issue.  If my code doesn’t help, we’ve got one of two possibilities:

  1. Lollipop doesn’t support it (be sure to try “lowProfile” too) properly.
  2. Corona is somehow not communicating this to Lollipop.

I’d file a bug, if still doesn’t work for you.

-Ed

PS Try the above with this too:

display.setStatusBar(display.HiddenStatusBar) -- Hide that pesky bar

your code is working!!! you are the first one that gives me solution thar working! you are very good.

but I have another question: now, after i useed your code I see that the game’s frame is a little bigger then the screen. (it was before also but I thought it was because of the nevigation bar. on galalxy s5/s4 it works good.

I am using this code for making the game’s frame fit for all screen sizes:

config.lua:

local aspectRatio = display.pixelHeight / display.pixelWidth

application =

{

content =

{

  width = aspectRatio > 1.5 and 1080 or math.ceil( 1920 / aspectRatio ),

      height = aspectRatio < 1.5 and 1920 or math.ceil( 1080 * aspectRatio ),

scale = “letterBox”,

fps = 60,

edit: it dosent good on nokia lumia to.

just a  little longer (the game is out  of the screen frame) 

Well … I  managed to offend one person today, so I hope this doesn’t offend you, but please read through this post and follow up on Brent’s suggestion and my last post about making a test bench and trying things.

If you do this, I think you’ll quickly understand how config.lua affects what you see on the screen and how you can best place items so they look good on multiple-resolutions.

This is one of those things you have to learn by doing.  Its hard for me (at least) to give a single answer because as I said in the other thread,

We all have different recipes that resonate with the way we work.

-Ed

ok thak you

One more thing.  I define these globals (some will say ‘evil’!) in all my apps:

\_G.w = display.contentWidth \_G.h = display.contentHeight \_G.centerX = display.contentCenterX \_G.centerY = display.contentCenterY \_G.fullw = display.actualContentWidth \_G.fullh = display.actualContentHeight \_G.unusedWidth = \_G.fullw - \_G.w \_G.unusedHeight = \_G.fullh - \_G.h \_G.deviceWidth = math.floor((fullw/display.contentScaleX) + 0.5) \_G.deviceHeight = math.floor((fullh/display.contentScaleY) + 0.5) \_G.left = 0 - unusedWidth/2 \_G.top = 0 - unusedHeight/2 \_G.right = w + unusedWidth/2 \_G.bottom = h + unusedHeight/2

These may help you.  Oh, and if you want to be ‘cleaner’ make a module to contain them.  I find a few globals are fine, but others will disagree.  I’m considering encapsulating this in a module in the future. 

As Corona has advanced, some of these have become redundant, but I keep them because I’m used to working with them.