Android Tutorial Designer Scripts & AutoScale Tutorial

incendio

Well-Known Member
Licensed User
Longtime User
Try to use Scale.SetRate(1).
This will strech the layout according to the new screen size.
No avail.

I end up with setup TextSize & Width manually and reposition its position with Scale.SetRight.
 

JAVIERGARCIA

Member
Licensed User
Longtime User
Hey there,
Copy this code to try another program, but always gives me a failure verticalcenter2.
I do not understand happens
You can help me,
Thank you
 

Attachments

  • Captura.JPG
    28.6 KB · Views: 383

klaus

Expert
Licensed User
Longtime User
Acording to the error message you use: Scale.VerticalCenter2(panel1)
This is wrong, VerticalCenter2 needs three parameter !

Explanation of Scale.VerticalCenter2(v As View, vTop As View, vBottom As View) means
Centers View v between two other views.
vTop is the view on top of v and vBottom is the view below v.
 
Last edited:

JoseJose

Member
Licensed User
"Attached you find a pdf tutorial about Designer Scripts & AutoScale."

==>Please, where is this PDF tutorial about Designer Scripts & AutoScale attached?
 

klaus

Expert
Licensed User
Longtime User
Sorry, it's no more included, Designer Scripts & AutoScale.pdf is outdated.
You should look in the Beginner's Guide which contains everything that was in the Designer Scripts & AutoScale.pdf document.
The Beginner's Guide has been updated several times including newer function.

I have changed the text in the first post.
 
Last edited:

stanmiller

Active Member
Licensed User
Longtime User
What's missing from this thread is the theory of operation behind the scaling module.

"For smartphone screens (< 6'') the views are scaled according to the screen width and the screen height without the rate factor. For bigger screens the scale factors are modified with the rate factor. For the big screens a rate value of 0 means no scaling and a value of 1 is equivalent to a scaling with %x and %y."

You can find those details and more in the first post of Klaus's sister thread here:

AutoScale Code Module
https://www.b4x.com/android/forum/threads/autoscale-code-module.23750/#content
 

klaus

Expert
Licensed User
Longtime User
The explanation in your post is valid only for the AutoScale Code Module, not for the AutoScale function in the Designer !

As written in the first post:
The pdf document has been removed, it is outdated.
The Beginner's Guide is updated with newer functions.


You find the theory of operation behind the scaling module in chapter 8.12 AutoScale in the B4A Beginner's Guide.

When this thread and the pdf document mentioned in the first post were written, the Anchor function in the Designer didn't exist.
 

stanmiller

Active Member
Licensed User
Longtime User
The explanation in your post is valid only for the AutoScale Code Module, not for the AutoScale function in the Designer !

Indeed. The AutoScale feature of the designer is well documented in the guide.

As a tutorial, new B4A developers trying their hand at developing for multiple display sizes will likely visit here first. The assumption in the first post is that readers are familiar with your AutoScale Code Module included in the attached AUTOSCALEEXAMPLE7.ZIP.

But there is no reference to where this code module comes from or much detail about what it does. The SCALE.BAS in that project is great work and a valuable learning tool going far beyond the function it performs. For example, the concepts of always thinking in dips, device scale, aspect ratio, and view tree traversing are all there.



More importantly, unlike the Designer's AutoScale you can modify the behavior of SCALE.BAS, as we did, to adjust for the "inside/out" scaling needed when the user changes the display font.

The challenges of dynamic font sizing are discussed in this thread.

Get size of system-font in use
https://www.b4x.com/android/forum/threads/get-size-of-system-font-in-use.28065/

I'll post our edits to SCALE.BAS and example usage in a new thread.
 
Last edited:

Guimarães

New Member
Licensed User
Mauro - Brazil
What formula to calculate the position and size of the elements. Xperia C
 

Attachments

  • Tela Lista.png
    46 KB · Views: 373
Last edited:

Guimarães

New Member
Licensed User
I created for my wife, an application to create grocery shopping lists, stock control and maturity of products. My family want a copy. I wonder if there is a calculation for n, I can include in the script.
Eg: ImageTodos left = 5, top = 34, whidth = 100, height = 100.
ImageTodos.SetLeftAndRight (n %x, n %x)
ImageTodos.SetTopAndBottom (n y% n %y)

Mobile Xperia C - 5 inch screen, resolution 540 x 960 pixel, 220 ppi.

I used Google translator
 

Attachments

  • Tela Lista.png
    46 KB · Views: 335
Last edited:

Guimarães

New Member
Licensed User
Sir,
Installed AutoScale Example7; when running displays the message:
"Unfortunately, AutoScaleExample7 has stopped."
 

Attachments

  • Captura de tela 2016-07-28 08.40.52.png
    295.2 KB · Views: 382

klaus

Expert
Licensed User
Longtime User
It's impossible for me to know what happens.
From your screenshot, there is no compiler error.
It seems that you are using an emulator.
Are you testing the program in Debug or Release mode ?
What exactly happens when you run the program.
Can you put a breakpoint at the beginning in Activity_Create and walk step by step through the program to see where the program stops.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…