display.statusBarHeight not reporting the correct height

I’m developing a portrait-only app and I want to support tall devices as well as display the status bar. My issue is with positioning an element directly under the status bar.

local heading = display.newImageRect(group, "assets/img/heading.png", 320, 62); heading.x, heading.y = display.contentWidth\*0.5, (31 + display.screenOriginY) + display.statusBarHeight;

This snippet works as-expected on iOS, but when I build and test it on my Samsung Galaxy S3 there’s a black bar roughly double the size of the status bar in between the bar and my image. Is this a known issue? any workaround? [import]uid: 194435 topic_id: 35226 reply_id: 335226[/import]

Hi @mdurrant,
What is the value of just display.statusBarHeight when you run on your S3? Can you print that value to the screen, without all of the other stuff factored in, and let me know what it equals?

Thanks,
Brent [import]uid: 200026 topic_id: 35226 reply_id: 140093[/import]

Actually, Corona returns the correct status bar height on all Android devices.
Corona returns the wrong height for iOS retina devices.
We’ve recently fixed this in daily build #1012.

Also note that [lua]display.statusBarHeight[/lua] returns the height of the status bar in *pixels*, not content coordinates. This means if your app is using Corona’s dynamic content scaling (ie: letterbox, zoomEven, or zoomStretch), then you need to convert pixels to content coordinates as follows…
[lua]-- Convert status bar height from pixels to content coordinates.
local statusBarHeight = display.statusBarHeight * display.contentScaleY[/lua]

One more thing… the Corona Simulator currently does not support Android status bars. That is, the simulator will not display an Android status bar onscreen and will always return zero for the height. Implementing this is on our to-do list, but no ETA since it is low priority at the moment…

Anyways, I hope this helps! [import]uid: 32256 topic_id: 35226 reply_id: 140153[/import]

Thanks guys. I upgraded to the latest daily build and applied the content scaling that Joshua suggested and everything works fine now. [import]uid: 194435 topic_id: 35226 reply_id: 140441[/import]

Hi @mdurrant,
What is the value of just display.statusBarHeight when you run on your S3? Can you print that value to the screen, without all of the other stuff factored in, and let me know what it equals?

Thanks,
Brent [import]uid: 200026 topic_id: 35226 reply_id: 140093[/import]

Actually, Corona returns the correct status bar height on all Android devices.
Corona returns the wrong height for iOS retina devices.
We’ve recently fixed this in daily build #1012.

Also note that [lua]display.statusBarHeight[/lua] returns the height of the status bar in *pixels*, not content coordinates. This means if your app is using Corona’s dynamic content scaling (ie: letterbox, zoomEven, or zoomStretch), then you need to convert pixels to content coordinates as follows…
[lua]-- Convert status bar height from pixels to content coordinates.
local statusBarHeight = display.statusBarHeight * display.contentScaleY[/lua]

One more thing… the Corona Simulator currently does not support Android status bars. That is, the simulator will not display an Android status bar onscreen and will always return zero for the height. Implementing this is on our to-do list, but no ETA since it is low priority at the moment…

Anyways, I hope this helps! [import]uid: 32256 topic_id: 35226 reply_id: 140153[/import]

Thanks guys. I upgraded to the latest daily build and applied the content scaling that Joshua suggested and everything works fine now. [import]uid: 194435 topic_id: 35226 reply_id: 140441[/import]