Skip to main content
September 6, 2011
Question

Android Air Soft Menu Height (to get portrait width in landscape)

  • September 6, 2011
  • 2 replies
  • 1505 views

I just realized that when I get the height and width of my main view after a screen rotation, the height is always smaller than the screen resolution because of the soft menu.

My problem is that I need to scale some text labels and to do so I need to get the ratio. If I hard code the ratio as (1280 / 800) it displays correct. However when I get the height programaticlly I end up getting (1280 / 752). The height 752 is accurate but not what I need. The soft menu on the Xoom must be about 48 px. What I need is (1280 / (752 + 48)).

I can't use Capabilities.screenResolutionX because we want to port the app to desktop and the screen resolution is often way bigger than the AIR window.

Does anyone know how I can get the full height including the soft menu? Or is there a way to get the portrait width some other way?

Thanks!

This topic has been closed for replies.

2 replies

Inspiring
February 6, 2012

Interesting the xoom give you 1280x752. I have a xoom family edition (almost the same device) and Capabilities.screenResolutionX and Y returns 1280x800.

Perhaps this will change with an OS update, its on 3.1 now.

I have it locked in landscape+fullscreen... not sure if that matters.

Jen, what does the Asus return for Capabilities.screenResolutionX and Capabilities.screenResolutionY ?

thanks

Inspiring
February 9, 2012

I actually get the same for Capabilities.screenResolutionX and Y (1280x800) and upon app startup, the values are correct if the device is held in Landscape mode. The first time I rotate it, it screws up. Here's what I get from the fullscreenwidth's on the sage object upon rotation complete:

StageOrientationEvent e.afterOrientation: rotatedLeft fullScreenWidth: 1280 fullScreenHeight: 752

When I rotate it back to "default" it's also screwed:

StageOrientationEvent e.afterOrientation: default fullScreenWidth: 800 fullScreenHeight: 1232

The strange part is that it simply looks as if these two values are swapped? In Default orientation, the lower 48 pixels are used for the menu so the value reported for "rotatedLeft" is the correct available height. The same is true for to opposite.

The code works nicely for my other two Android testing devices, so it has to have something to do with the soft-menu, but how can I detect it in AIR?

J

September 13, 2011

I noticed that the Samsung Galaxy gives 1280x800 in landscape and the Xoom gives 1280x752. So each device is diffrent!

trace(Capabilities.screenResolutionX + "x" + Capabilities.screenResolutionY);

Inspiring
February 6, 2012

Hi Paul.

I have the very same problem just now and I can't seem to find a way to detect this properly.

I'm using an Asus Tab and it returns the incorrect width/height, that is - it's lagging a rotation behind

Did you solve this issue in a reliable way?

J