Status bar height issue

Jeremy,

It’s definitely a bug in your code.  It’s caused by your usage of the “display.screenOriginY” property which provides the y component of the top-left coordinate of the screen in “content coordinates”.  Since your app is set up to be letterboxed, this property will provide a negative y value if a letterbox bar is shown at the top of the screen… which will be the case for the vast majority of Android devices.  Your code is not compensating for this negative value, causing it to place your text objects higher up on the screen than you expect.

It’s easy to prove.  Just print the screen origin to the log.  You’ll see that it’s a negative value.

   print("Screen Origin Y = " … tostring(display.screenOriginY))

The reason you’re not seeing this issue on an iPhone 5 is because your app is running in backward compatibility mode.  In order for your app to support “tall mode”, you need to add a “Default-568@2x.png” to your app folder as documented in the link below.  That will cause your app to use the entire screen, force Corona to letterbox the app itself (which iOS was doing for you in backward compatibility mode), and then you’ll see this same issue happening on your iPhone 5.

   http://docs.coronalabs.com/daily/guide/distribution/buildSettings/index.html#launch-images

I don’t know much about Jeremys issue, but in my case I’m always trying to position things like that:

rect.y = display.screenOriginY + display.topStatusBarContentHeight

and despite the fact that I’m doing this I was having this problem on a s4 recently.

of course I would need to do further testing ( which I currently don’t have the chance to) before pointing out where the bug is…

I’m having a Default-568@2x.png

maybe I’m getting it all wrong…

Hold on.  I see what’s going on.  You’re right.  The status bar height is being returned wrong for “xxhdpi” Android devices.

You can work-around it by doing this…

if (system.getInfo("androidDisplayDensityName") == "xxhdpi") then statusBarHeight = 75 \* display.contentScaleY else statusBarHeight = display.topStatusBarContentHeight end

The above will work on all platforms.  It checks if you’re running on an xxhdpi Android device, in which case the status bar height is supposed to be 75 pixels tall.  Multiplying pixels with “display.contentScaleY” will convert it to content coordinates.

Thanks Joshua.  That’s what I needed.  I’ll give that a try tonight.  I appreciate your help.

Thanks for work-around Joshua.

So I understand that it is in fact a bug and Corona will fix that in incoming daily build, right?

Renato

Yes, it’s confirmed to be a bug in Corona on xxhdpi Android devices.  We’ll fix it in a daily build in about 1-2 weeks.  Daily builds are currently on hold since we’re in the middle of pushing out a new release version of Corona.

@Joshua Quick

Wow what a great timing! Gonna submit my app to the store tomorrow.

Thanks a lot.

Roman

The API  display.topStatusBarContentHeight is returning a status bar height on my Galaxy Tab 10’’ (GT-p7510) Android 4.0.4 starting with build 2076. Before this build (Graphics 1.0) the height was ok on all devices. 

Please note that there is no status bar and the value should be 0

Was this fixed in the public release or do I need to use the workaround?

>> Was this fixed in the public release?

Unfortunately no.  Our team was more focused in resolving graphics 2.0 issues that came up in the last release.  So, you’ll still need to use the above work-around.

Hi,

As of daily build 2109, display.topStatusBarContentHeight wiil return the correct value for xxhdpi devices.

The API  display.topStatusBarContentHeight is returning a status bar height on my Galaxy Tab 10’’ (GT-p7510) Android 4.0.4 starting with build 2076. Before this build (Graphics 1.0) the height was ok on all devices. 

Please note that there is no status bar and the value should be 0

Was this fixed in the public release or do I need to use the workaround?

>> Was this fixed in the public release?

Unfortunately no.  Our team was more focused in resolving graphics 2.0 issues that came up in the last release.  So, you’ll still need to use the above work-around.

Hi,

As of daily build 2109, display.topStatusBarContentHeight wiil return the correct value for xxhdpi devices.