Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting screen size problem #111

Open
Sylph opened this issue Dec 15, 2012 · 3 comments
Open

Detecting screen size problem #111

Sylph opened this issue Dec 15, 2012 · 3 comments
Labels

Comments

@Sylph
Copy link
Contributor

Sylph commented Dec 15, 2012

Basically, we know that line 47 RNFactory
local screenX, screenY = MOAIEnvironment.screenWidth, MOAIEnvironment.screenHeight
has changed to
local screenX, screenY = MOAIEnvironment.horizontalResolution, MOAIEnvironment.verticalResolution
on newer MOAISDK builds,

But this still doesn't take into account the status bar size in several devices I've tested (Archos 70 IT running Android 2.2)
I have to replace line 75-76
RNFactory.width = lwidth RNFactory.height = lheight
with
RNFactory.width, RNFactory.height = MOAIGfxDevice.getViewSize()

to get the proper screen size so that the viewport doesn't overlap with the status bar on the archos, but it the bottom is still cut off when using HTC inspire (running Jelly Bean). I'll research more on this.

@Sylph
Copy link
Contributor Author

Sylph commented Dec 17, 2012

It seems that at least on my android (2.2), MOAIGfxDevice.getViewSize() return 0 even at the beginning of RNFactory.init method, but on windows it only return a value after MOAISim.openWindow is called.
The same behaviour happens with MOAIEnvironment.horizontalResolution and MOAIEnvironment.verticalResolution.

So changing the first part of RNFactory.init() to the following would make sure that the app can detect the screen size appropriately (taking into account status bars), at least for android and window host.

function RNFactory.init()
    local lwidth, lheight, screenlwidth, screenHeight
    local screenX, screenY = MOAIGfxDevice.getViewSize()

    if screenX ~= 0 then
        lwidth, lheight, screenlwidth, screenHeight = screenX, screenY, screenX, screenY
    else

I don't have access to an ios device right now to test that.

@MattiaFortunati
Copy link
Collaborator

Hi Sylph,

I've changed

if screenX ~= nil then

to

if screenX ~= nil and screenX ~= 0 then

this should work to fix the problem. Tested on my Android and iOS devices.

Thanks for the issue, sorry but on my Android the previous code worked well :D

@Sylph
Copy link
Contributor Author

Sylph commented Mar 25, 2013

Yw. :)
I'm using Unity3D at the moment, so i may not participate much anymore,
anyway good luck. ^^

On Mon, Mar 25, 2013 at 8:30 AM, Mattia Fortunati
notifications@github.comwrote:

Hi Sylph,

I've changed

if screenX ~= nil then

to

if screenX ~= nil and screenX ~= 0 then

this should work to fix the problem. Tested on my Android and iOS devices.

Thanks for the issue, sorry but on my Android the previous code worked
well :D


Reply to this email directly or view it on GitHubhttps://github.com//issues/111#issuecomment-15390381
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants