Android Question Module Scale "issues"

LucaMs

Expert
Licensed User
Probably I forgot how to use the module Scale.

Starting from this example layout (variant 480x320-1):
upload_2018-3-31_15-7-54.png



On my tablet (1280x800-1):
upload_2018-3-31_15-10-25.png


Code used (no scripts):
B4X:
    Activity.LoadLayout("Lay1")
'    Scale.Rate = 0.3
    Scale.Initialize

    Scale.ScaleAll(Activity, True)
Why Button2 is not placed correctly?
 

Attachments

LucaMs

Expert
Licensed User
In the project I wrote also:
B4X:
' *** Code below "works".
    Activity.LoadLayout("Lay2")
    Scale.SetReferenceLayout(1280,800,1)
but this is wrong; it works because I tested the layout on a device with the same resolution and density of the layout. On another device, 800x480-1.5 it looks so:
upload_2018-3-31_15-23-9.png


Note also the strange "color" of buttons (I have not set colors).
 

klaus

Expert
Licensed User
You should NOT use anchors nor any designer scripts these will alter the scale function.
SacleAll is the same as %x and %y.
Remember, the Scale module was written before anchors did exist.
 

LucaMs

Expert
Licensed User
You should NOT use anchors
Well, I cannot exclude anchors totally; I have reset the default anchors for Button2 (and removed the script for Label1) but now the result is:
upload_2018-3-31_15-51-55.png


B4X:
    Activity.LoadLayout("Lay1")
'    Scale.Rate = 0.3
    Scale.Initialize
    Scale.ScaleAll(Activity, True)
 
Last edited:

klaus

Expert
Licensed User
Sorry, for an %x and %y scaling, on tablets, you need to set Scale.Rate = 1.
If you use a ScaleRate less than 1 you need to reposition the views.
Or put the layout onto a Panel and center this one.

It's quite some time time that I hadn't have a look the this module.
 
Top