Android Question Adjust for screens with different resolutions

yaniv hanya

Active Member
Licensed User
So far I have developed the app on a 7 inch screen at 1024/600 resolution today I received a new device with screen of the same size but at 1280/720 resolution and the screens I built are too big and out of the screen.
I thought the designer values were in Deep and that should solve this problem, isn't it?
Is there a way to arrange it programmatically or just fix the design in the designer?
And is there a way to worry about it not happening again on another device?
 

emexes

Well-Known Member
Licensed User
So far I have developed the app on a 7 inch screen at 1024/600 resolution today I received a new device with screen of the same size but at 1280/720 resolution and the screens I built are too big and out of the screen.
It's not that your existing screens are too big, it is that the aspect ratio has changed, and the scaling calculation seems to trust that you have used anchors in the right and bottom areas of the layout.

Also, an AutoScaleRate less than 1 (default is 0.3) means that items are not enlarged/moved as much as the screen dimensions have grown, eg, if you change to a device that is twice as large (eg from a 5" display to a 10" display) then your buttons etc will likely only grow in size by 30%, rather than the 100% (double) that you might expect.
Is there a way to arrange it programmatically
Designer script is usually straightforward. Or instead of using AutoScaleAll, you could do your own scaling to fit the returned LoadLayout() LayoutValues to the device, although if the aspect ratios are different, you'll end up with some blank border on the vertical or horizontal edges. But apparently I am the only person who likes this approach.
or just fix the design in the designer?
If you only have a couple of layouts to vary, it may well be simpler and quicker to just add another variant for the new aspect ratio, tweak the positions in the new variant, be done within 5 minutes. There is a school of thought that has taken the reasoning more variants = more things to keep updated = more complex, and extrapolated that to multiple variants = bad, except maybe for portrait/landscape. My thought is that if a tool is available and it does the job... go for it.
And is there a way to worry about it not happening again on another device?
Ripper sense of humour you have there :) ... What?? ... Wait, what do you mean, that question wasn't a joke?!?!
 
Last edited:

yaniv hanya

Active Member
Licensed User
And is there a way to worry about it not happening again on another device?
sorry I meant to ask this:
Is there a way to prevent this from happening again on another device?
 

Erel

Administrator
Staff member
Licensed User
It is a mistake in most types of apps regardless of the aspect ratio. There is no reason for a button to increase its size more than 2cm * 2cm. In most applications there are views that are expected to fill the available space. These views are usually anchored to BOTH sides. If the layout should be static then put it in a panel in the center of the screen.
 
Top