Skip to main content
Inspiring
November 7, 2011
Question

proper layout on multiple screen sizes

  • November 7, 2011
  • 1 reply
  • 1063 views

I have an app created at iPhone4 screen res (640x960)

Now I want it to scale properly on an android tablet (800x1200).

this looks good

stage.scaleMode = StageScaleMode.NO_BORDER;

But how to I query the size for my buttons?

I use the capabilities class to get the screen dpi and layout the button sizes based on pixels, works good

however StageScaleMode.NO_BORDER, it appears I am just scaling the whole swf, thus making my buttons too large.

thanks

This topic has been closed for replies.

1 reply

relaxatraja
Inspiring
November 7, 2011

You have to resize the every element according to the new size or else maintain the same size using the

stage.scaleMode = StageScaleMode.NO_SCALE;

swfisgoodAuthor
Inspiring
November 7, 2011

here is the problem: there seems to be no way to read the new "real" size?

I can't use NO_SCALE... because i need it to scale up.

if i use StageScaleMode.NO_BORDER; the size of the main app looks good.

the problem is getting the real size to make the overlaying buttons

after setting scaleMode, it scales accordinly but if i trace

this.height or stage.height // original size

scaleX or stage.scaleX // 1

it returns as if nothing was scaled, so the REAL coordinate system is now unmeasureable.

when i size and place my buttons, they are of the stage coordinates which reads unscaled, when truly everything is scaled and there seems to be no way to mesure it.

I had read comments where you can take a retna display app, and alow it to scale down on the 3gs... same aspect ratio so it scales perfect.

But you must run into the same situation? You layout and size the buttons based on  screen resolution, screen DPI, height/width

... but then its all irrelivent when the app scales down your buttons are 1/4th the size again?

On iOS theres only a few devices and you can get the exact one from capabilities class, so i assume its easier to work around. Not so on android.

Its almost like if you scale up a Sprite, within that sprites coordinate system, you would use localToGlobal or trace scaleX/scaleY .... but in this case, i cant find a global system higher than stage!?

The only work around i can think is predict how much it is going to scale based off stage.width and screen resolution.

set the scaleMode.

take that %Scale prediction and apply it to the button layout scale and positioning

Am I missing something obvious here?


Participating Frequently
November 7, 2011

I think you will want to use one technique or the other. Either use the automatic stage scaling and draw things at a single size. Or set the scale mode to noScale and use the screen size and dpi to programmatically determine size and layout. Don't try to do it both ways.