Android Question AutoScaleRate not working!

adrianstanescu85

Active Member
Licensed User
Longtime User
Hello

I'm working on a larger project and I usually use phones that are 480 x 800 px and 240 dpi. However, I just received a newer 540 x 960 px phone with the same 240 dpi, so I figured I should take a look to adjust the elements to the new resolution.

As before (that is before B4A 3.20) I went over to the Designer, added the new resolution, set a certain AutoScaleRate, ran it, and... nothing happened! The screen stays the same (i.e. how it looks like with the same 480 x 800 px by 240 dpi screen), with a large unfilled space at the right side and bottom. I set the AutoScaleRate and AutoScaleAll to test for the current variant, for all variants... the idea is the same. Noting works?

What am I doing wrong?

To test that, I just put up a simple sample that basically does nothing except show a large label and button, it fills almost all the screen on 480 x 800 but the problem remains on 540 x 960. So that basically shows the inconvenience.

I've attached the whole project, maybe someone can have a look and let me know what am I doing wrong. I'd very much need to get the elements resized to the new screen dimension!

Please help!

Thank you!
Adrian
 

Attachments

  • Test App.zip
    329.7 KB · Views: 255

adrianstanescu85

Active Member
Licensed User
Longtime User
They have different aspect ratios, 480 x 800 is 1.66 ratio and 540 x 960 is 1.77 ratio, so normally with any (working!) scale I would expect a right empty space, which is normal to appear since the difference in aspect ration, but the overall resize would take place. I.E. a label 100x100 px for the first phone would be about 112x112 px for the larger screen. That doesn't happen! Since I started working in B4A 3.20 for more than a month already, all the modifications to the layout file are made in this new format, which is incompatible with older versions.

So... what to do??
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I would do it like in the attached modified project.
One layout variant and using anchors in the Designer and also the Designer Scripts.
Button1 has:
vertical anchor BOTTOM, anchors the bottom to the screen with a margin.
horizontal anchor BOTH, fills the screen horizontally with a margin.
Label1 has
vertical anchor TOP
horizontal anchor BOTH, fills the screen horizontally with a margin.
DesignerScripts Label1.SetTopAndBottom(44dip, Button1.Top - 16dip), fills the space between the top of the screen and the top of Button1.
 

Attachments

  • Test App1.zip
    7 KB · Views: 225
Upvote 0

RDCrozier

Member
Licensed User
Longtime User
I know this is a rather old post, but I am having a similar problem to the one stated above. I tried to sort it in the way that Klaus explained (setting anchors on the sides at the edge of the display, and then use the scripts to get the relational sizing.)

However when i click from the abstract designer to the script view the points that I have anchored jump from the edge of the display, both from the left and top edges.

I could write these points into the script but then wouldn't that defeat the point of having the abstract designer? I just want to combine the two.

Thanks in advance
Dave
 
Upvote 0

RDCrozier

Member
Licensed User
Longtime User
In the example below I set the top and left anchor of button 2 in the abstract designer (as it is in the top left). I then write a script which sets the right and bottom properties of the button as percentages of the screen size (so as to re-size according to whichever screen size it is running on). However when i run the script it seem to forget the left and top positions when setting the position for right and bottom. Hope this makes sense.

Thanks
Dave
 

Attachments

  • Scaling Test.zip
    359.6 KB · Views: 244
Upvote 0
Top