Nexus 7 gen 2 borders problem

Hi, everyone!
I am having a little problem while running my app on nexus 7 second generation device. The resolution on it is not standart(16x10), because of the placement of android menu bar. So, the app cant define the borders.

Everything works fine in simulator, and on other devices, maybe the solution is to make a check in the app whether it is nexus, and place objects 20 pixels left?

I would be very greatful, if you can help me!

What does your config.lua look like?

if ( string.sub( system.getInfo("model"), 1, 4 ) == "iPad" ) then application = { content = { fps = 60, width = 360, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" and display.pixelHeight \> 960 ) then application = { content = { fps = 60, width = 320, height = 568, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" ) then application = { content = { fps = 60, width = 320, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( display.pixelHeight / display.pixelWidth \> 1.72 ) then application = { content = { fps = 60, width = 320, height = 570, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } else application = { content = { fps = 60, width = 320, height = 512, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } end settings = { android = { usesPermissions = { "android.permission.INTERNET", }, }, }

You might want to look at this blog:

http://www.coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/

It does a bit better with Android devices than the previous version that you seem to be using.

Rob

So these few lines code

--calculate the aspect ratio of the device local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 800 or math.ceil( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.ceil( 800 \* aspectRatio ), scale = "letterBox", fps = 30, imageSuffix = { ["@2x"] = 1.3, }, }, }

can repace all those lines of the ultimate config lua file that I have?

Still this new config.lua file doesn’t help.
But I found some logic in this border problem:

When the app is launched(!) in landscape position and it is not being changed to portrait, and then the scene is created - there is no problem with borders, but then if i do rotation to portrait, the border of the size of the android menubar occured.

When the app is launched for example again in landscape, but then immidiately rotated to portrait, and after that i launch the creation of the problematic scene, the borders problem occured again.

I thought problem was in some conflicts in onOrientationChange event, but then i tested the thing, where after every changing of orientation the x coord of the object refreshes to 0, but it still doesn’t work.

I hope i understand me.

I would substitute 320 and 480 for the 800 and 1200 numbers so you don’t have to change your entire project. 

What does your config.lua look like?

if ( string.sub( system.getInfo("model"), 1, 4 ) == "iPad" ) then application = { content = { fps = 60, width = 360, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" and display.pixelHeight \> 960 ) then application = { content = { fps = 60, width = 320, height = 568, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" ) then application = { content = { fps = 60, width = 320, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } elseif ( display.pixelHeight / display.pixelWidth \> 1.72 ) then application = { content = { fps = 60, width = 320, height = 570, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } else application = { content = { fps = 60, width = 320, height = 512, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } end settings = { android = { usesPermissions = { "android.permission.INTERNET", }, }, }

You might want to look at this blog:

http://www.coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/

It does a bit better with Android devices than the previous version that you seem to be using.

Rob

So these few lines code

--calculate the aspect ratio of the device local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 800 or math.ceil( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.ceil( 800 \* aspectRatio ), scale = "letterBox", fps = 30, imageSuffix = { ["@2x"] = 1.3, }, }, }

can repace all those lines of the ultimate config lua file that I have?

Still this new config.lua file doesn’t help.
But I found some logic in this border problem:

When the app is launched(!) in landscape position and it is not being changed to portrait, and then the scene is created - there is no problem with borders, but then if i do rotation to portrait, the border of the size of the android menubar occured.

When the app is launched for example again in landscape, but then immidiately rotated to portrait, and after that i launch the creation of the problematic scene, the borders problem occured again.

I thought problem was in some conflicts in onOrientationChange event, but then i tested the thing, where after every changing of orientation the x coord of the object refreshes to 0, but it still doesn’t work.

I hope i understand me.

I would substitute 320 and 480 for the 800 and 1200 numbers so you don’t have to change your entire project.