Text AutoScale with Designer

sterlingy

Active Member
Licensed User
Longtime User
I'm trying to fully understand the AutoScaling, method.

I built my layout with Designer and everything seems to scale except TextSize of labels.

See attached image.

I'm using AutoScaleAll.

The two screenshots represent a 600x960 and a 320x480 screen, both at 160dpi (scale = 1)

Designer Script code:

B4X:
'All variants script
AutoScaleRate(1)
AutoScaleAll 

pnlScoreboard.SetLeftandRight(0%x,100%x)
pnlScoreboard.SetTopandBottom(0%y, 8%y)

lblScore.Left = 2%x
lblScore.VerticalCenter = pnlScoreboard.VerticalCenter - 1.5%y
lblScore.TextSize = 28

pnlTouchPad.SetTopAndBottom(70%y, 100%y)
pnlTouchPad.SetLeftandRight(0%x,100%x)

pnlController.Height = 125dip
pnlController.Width = 125dip
pnlController.HorizontalCenter = 50%x

pnlGameWindow.SetTopAndBottom(pnlScoreboard.Bottom, pnlTouchPad.Top)
pnlGameWindow.SetLeftAndRight(0%x, 100%x)

lblLvl.Top = pnlScoreboard.top - 1%y

lblLvl.Left = 35%x
lblLvl.TextSize = 18

lblDogsRemain.Right = pnlScoreboard.Right - 1.5%x
lblDogsRemain.Top = pnlScoreboard.Top - 4.25%y
lblDogsRemain.TextSize = 18

lblCatsRemain.Right = pnlScoreboard.Right - 1.5%x
lblCatsRemain.Top = pnlScoreboard.Top - 1%y
lblCatsRemain.TextSize = 18

pnlShovels.SetTopandBottom(pnlScoreboard.Top +3dip, pnlScoreboard.Bottom - 3dip)
pnlShovels.Width = 19%x
pnlShovels.Left = pnlScoreboard.Left +60%x

Also note that the white circle at the bottom did not scale.

Thoughts?

-Sterling
 
Last edited:

sterlingy

Active Member
Licensed User
Longtime User
Klaus,

Two things:

1. I'm confused. If I set everything up in the designer, using the standard 320x480 variant, everything looks fine. Why would I change the text size, that would just make it a size I don't want.

And where do I change the size to a unique value, in the scripts panel or in the main window where you set view object properties?

2. Any Idea why the circle isn't scaling?

-Sterling
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Now, I don't understand what you want.
Do you want the text size scaled according to the screen size or do you want a fixed size ?
In the script code you posted you have AutoScaleAll at the beginning which scales the text size of all views having text.
Then below you have three lines like this one lblLvl.TextSize = 18 where you set the text size to a fixed value. So the text size for these labels will be the same on all screens.
For the circle, I don't know what you have done. There are no screenshots.

Best regards.
 
Upvote 0

sterlingy

Active Member
Licensed User
Longtime User
Klaus,

Sorry my code was confusing. I was playing with various options, and I copied the wrong code. Needless to say, I now have the text scaling properly between devices, but since the position of the labels moves around a bit, their associated text gets a bit out of alignment. I suppose this is one of the compromises of AutoScale. I did play with adding variants, and this actually gave me better results.

The white circle that I referred to is in the image I originally posted. You see it at the bottom of the two screenshots. I doesn't scale. I'm sure I'll figure it out.

-Sterling
 
Upvote 0
Top