Full Screen on Android

Hello! I have a project using OpenFL and HaxeFlixel that I’m trying to get running on android. An issue I’ve run into is that on my android device, the game is letterboxed vertically with black bars on the left and right (it runs in landscape). I’m using the following line in my project.xml:

	<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />

However, as a test, if I set it to the resolution of my device (Moto G), as below, then it fills the whole screen as desired:

	<window if="mobile" orientation="landscape" fullscreen="true" width="1280" height="720" />

Obviously though I want to keep the width and height values at zero, so that it scales correctly for different resolutions. This works fine on iOS - on all devices, the game fills the whole screen correctly. Any ideas why setting the width and height to zero in the project.xml wouldn’t give me the correct screen resolution?

I guess it’s related to screen ratio?

since you are using haxeflixel
maybe you can try different scale mode?

you can also write you own scale mode base on BaseScaleMode

That was my thought initially too, and I’m able to get it sized correctly in haxeflixel if I hard code the resolution values to my device’s resolution (rather than using Lib.current.stage.stageWidth & stageHeight), but the issue still seems to be that these stageWidth and stageHeight values are incorrect. Plus, running on a device with a screen resolution of 1280 x 720, I think these should be equivalent:

<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />


<window if="mobile" orientation="landscape" fullscreen="true" width="1280" height="720" />

But they are not. I think I’m narrowing it down though. This phone doesn’t have hardware buttons for those three android buttons (home/back/apps, I’m not sure what this bar is called). Instead, you swipe down when a fullscreen app is running and they pop up on the screen. The space they take up seems to be the same amount of space that I’m losing, only distributed over each side of the screen. I’m assuming that OpenFL makes some call to figure out the screen size when you provide it with width and height of zero, and whatever call this is is returning the size minus the space for those buttons. Sorry if this is hard to follow, I haven’t developed on android before so I’m figuring it out as I go. I’ll look into it some more, see if I can find where OpenFL makes the call to get the screen size and do some investigation.

Seems like the little software bar is the issue, based on posts like this i am finding:

Since some devices have the little bar on screen all the time, it’s not safe to use getRealSize() instead of getMetrics() on the screen as far as I can tell, which was my initial idea.

Can you reproduce it with the SimpleSWFLayout sample project? Post a screenshot if so.

Are you handling Event.RESIZE events?

That was the issue, thanks - not handling resize events. I get a resize event right after starting the game as the little software bar goes away. Thanks for the help!

1 Like