Android Question Autoscaleall (again, sorry :-( )

LucaMs

Expert
Licensed User
Longtime User
I'm using percentages, when create my GUIs, but I would like to use better the Designer.

Foreword: I know well the problem of the different relationships (ratio) between width and height of the various devices (when the hardware manufacturers will agree a standard, better if 16:9? ).

What I think is expected from the Autoscale functionality is that, roughly, when you create a variant including a button 100dip x 100dip, using the Autoscaleall the button is sufficiently proportioned on devices with different screens, such as tablets and smartphones.

In the example that I attach, I left all the default settings; I just added a button (default size, 100dip x 100dip).

Data and result:

TABLET 800 x 1280 - scale 1 (density)
SMARTPHONE 480 X 800 - scale 1.5


Variant: 320 x 480
Button1: 100 x 100
AutoScaleRate: 0.3 (not set, implied).

LOGS (Button1 size):
TABLET 150 X 150 (dips)
SMARTPHONE 155 X 155 (dips)


The difference is evidently minimal and consequently the proportion between the button and the screen size is totally different from what is desired.
[Moreover, the size in dips on the smartphone is even greater than on a tablet]


Since surely Autoscale does what it was created for, obviously what I suppose it should do is wrong.
 

Attachments

  • Autoscale - button.zip
    7.7 KB · Views: 265

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
LogColor("Button1 size: " & Button1.Width & " x " & Button1.Height, Colors.Blue)
This line doesn't print the size in dips. It print the actual number of pixels.
You should compare the normalized sizes:
B4X:
Dim scale As Float = GetDeviceLayoutValues.Scale
LogColor($"Button 1 size: $1.0{Button1.Width / scale} x $1.0{Button1.Height / scale}"$, Colors.Blue)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
This line doesn't print the size in dips. It print the actual number of pixels.
Anyway, the height of the button (scaled) is almost equal on my smartphone (155px / 800px) and my tablet (150px / 1280px), resulting, therefore, disproportionate to the height of the screen, almost as if I wanted a fixed height (which I think I would get if I set the value to Ndip by code).

A designer script that seems to improve things is this:
B4X:
DefTextSize = 1.0

If ActivitySize <= 6 Then
    AutoScaleRate(.75)
    DefTextSize = 14
Else
    AutoScaleRate(1)
    DefTextSize = 16
End If

(probably adding a couple of "Else If" and related values, it would work even better).
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The number of pixels do not have any meaning without the scale.
The correct values based on what you wrote are:
Tablet - button size is 1.3 inch (Sqrt(Power(150/160)*2))
Phone - button size is 0.9 inch (Sqrt(Power(155/1.5/160)*2))

AutoScaleAll worked perfectly and as it is designed. It slightly increases or decreases the views sizes based on the difference between the variant size and the device size.

As I tried to explain to you many times in the past AutoScaleAll doesn't stretch the layout. A tablet layout shouldn't be a proportionally stretched layout like a huge phone.
If you do want to stretch the layout then you shouldn't use AutoScaleAll.

We already had this exact discussion 10 times in the past. So it is better that I will stop now and not try to convince you that it is correct.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
You're just starting to understand LucaMS now ...
If it does not hit 20 times it does not convince ... you have only arrived at 11 explanations ... 9 others are missing to convince and understand
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
We already had this exact discussion 10 times in the past. So it is better that I will stop now and not try to convince you that it is correct.
This was the reason why I asked you the question in private, since it seems to you that I want to say that Autoscaleall does not work and therefore I want to diminish its value; but you told me to open this thread.

It slightly increases or decreases the views sizes based on the difference between the variant size and the device size.
Well, I do not understand the purpose, if the layout is not, for example, loaded in a panel but it must cover the whole screen. It is evident that I did not understand the purpose of variants. I will try to read this topic again in the pdf.


Thank you for your patience, for having preferred the question in public to then respond in this way!


Thanks also to @Star-Dust for his very useful comment.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I was encouraging Erel to answer you 9 more times, it's quite useful since he stopped answering you
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User

An excellent and 100% perfect example.
So at a glance if a button is 100x100 at a scale of 1.5, the first line will return 150x150 and the second line will return 100x100 at a scale of 1.5. Wait a minute, that's the correct way around isn't it, hmm.

Yes it is, phew.

C'mon @LucaMs, just chillax matey. Have a glass of wine and watch a great movie on the box, I highly recommend 'The Usual Suspects' or 'T2', both classics...
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
C'mon @LucaMs, just chillax matey. Have a glass of wine and watch a great movie on the box, I highly recommend 'The Usual Suspects' or 'T2', both classics...
"The usual suspects" are over at this moment in Italy. Maybe tomorrow
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
A phone with screen 3.8" and a phone with 5.8", with or without the same scale, should show the same layout, "proportionally stretched".

Firstly you're the expert here not me. If you are having such HUGE issues, why don't you just create multiple layouts?

That's a serious question, I'm not taking the pee..

https://developer.android.com/training/multiscreen/screensizes.html
https://developer.android.com/guide/practices/screens_support.html
https://developer.android.com/training/basics/supporting-devices/screens.html
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I don't use percentages as much as I used to, especially since the introduction of anchors, but I still use percentages when I have to, the same as you I presume.

And watch 'The Usual Suspects'
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…