Android Question AutoScale Question

margret

Well-Known Member
Licensed User
Longtime User
I have a layout with AutoScale code. The code is the exact same in both images except for an If Condition, yet the two yield completely different results. Anyone know why? You can see the layout size and the script code in each condition. They should both be the same.

untitled1.jpg

untitled2.jpg
 

Mahares

Expert
Licensed User
Longtime User
My understanding is that you should always use dips or % in the designer script, except if you are dealing with text size. I do not know if using dips for the panel width here will solve your issue.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Margret,
The tiny value of -0.001 in my opinion, relates to the tiny change in the scale that's barley noticeable.
That logically suggests that the condition is being processed and executed! but this is impossible since
the condition lines are commented out.
so... to my two cents..
The microprocessor of your computer is too lazy it is reusing previously calculated value, when the project
first run before the condition was commented, and I would suggest you clean up the cache and collect I don't know what.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
The script code is listed under each layout that is displayed. I am not running any app, this is displayed on the device in the designer and the only thing that is running is the script. The line you pointed out is never used, it is commented out in both cases. You can see the uncommented script code for each one in each image.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Alright..

According to my experience with the layout.. one must save the layout each time a new view is added.
Try to save the layout using "Save As..." NOT "Save", and then give it, of course the same name and replace... etc.
May be some of recently added views are not AutoScalling because simply are not saved. just give it a try
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Since your layout is variant specific, I do not think you should use: AutoScaleAll in the Designer Script, at least I never did. In fact if you comment AutoScaleAll, the layout is the same whether the If-End if block is commented or not.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I tested your layout file with B4A versions 3.20 and 3.50.
I don't see any defference in the Abstract Designer with or without the If statement.
Two things look strange to me:
- the width of Enotesee2 is wider than the screen width, why.
- AutoScaleRate(-.0.065) looks very strange to me, what do you expect with this value ?
According to the equations of AutoScale, a value of AutoScaleRate = -.0.065 will have almost no effect on the layout.
I really don't understand what you excpect with this value.
As Mahares already pointed out, why do you use AutoScaleAll in a specific layout.
This is a sample for something I will be working on.
Can you be more precise on what you want to do and what you expect.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
My goal is to design one variant in landscape for a selected device, it is 1024 x 800 - scale = 1. I then would like to scale that variant up or down, in code/script to fit the screen of other devices that may be 800 x 600, 1980 x 1200, etc. The layout is not conducive to anchor points as there are many views off center, both vertically and horizontally.

As I have said, the layout and any code I have posted here are samples and for testing purposes. Also, you will not see any difference with 3.2 or 3.5, as it will not run the script by pressing F5, 3.0 will run the script. Erel said, if the layout matches the device the script will not run(in newer version). But I find it will not run at all even if you are close. I have changed the layout by a couple of hundred dpi and it still will not run the script. There are others with more knowledge than I, that have tested this and found the same results I did.

You can force the newer version to show this by adding this code and see the difference at runtime, but they can not been seen by just running the script in the designer(pressing F5).

B4X:
Dim jo As JavaObject
jo.InitializeStatic("java.lang.System").RunMethod("setProperty", Array As Object("autoscaleall_old_behaviour", "true"))
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Let's see if this helps. Image "st1.png" is the layout loaded in the designer and displayed on the device with no script. Screen shots taken with B4A.

Image "st2.png" is the same but with this script running:
B4X:
'Variant specific script: 960x544,scale=1
amt = -.0650
'If PanelMain.Width > 700dip Then
    AutoScaleRate(amt)
    AutoScaleAll
'End If

Image "st3.png" is the same but with this script running:
B4X:
'Variant specific script: 960x544,scale=1
amt = -.0650
If PanelMain.Width > 700dip Then
    AutoScaleRate(amt)
    AutoScaleAll
End If
 

Attachments

  • st1.png
    st1.png
    32.5 KB · Views: 285
  • st2.png
    st2.png
    36.7 KB · Views: 248
  • st3.png
    st3.png
    33.7 KB · Views: 256
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I've tried it on V3.0 and can see the issue. It's even stranger if you make a change.

I tried moving BNCan.Top just to make sure it was running the code in the If block and the layout changes again.

B4X:
amt = -.0650
If PanelMain.Width > 700dipThen
     'BNCan.Top = 0
     AutoScaleRate(amt)
     AutoScaleAll
EndIf
Try running it, then un-commenting the BNCan.Top line.
 
Upvote 0
Top