Android Question AutoScale delta adjustment

JdV

Active Member
Licensed User
Longtime User
Hello

I'm trying to get a simple layout (320 x 480) to AutoScale up and fit larger resolution devices without it going off the screen.

If I understand Kalus's tutorial correctly then the relevant formulae at work here are as follows:
delta = ((100%x + 100%y) / (320dip + 430dip) - 1)
rate = 0.3 'value between 0 to 1.
scale = 1 + rate * delta

The rate determines the change amount in relation to the device physical size.
Value of 0 means no change at all. Value of 1 is almost similar to using %x and %y: If the physical
size is twice the size of the standard phone then the size will be twice the original size.

If I want the layout to fill the screen on a device with a resolution of 640 x 860 (for example) it follows:
delta = ((640 + 860) / (320dip + 430dip) - 1) = ((1500 / 750) -1 ) = (2-1) = 1
rate = 1
scale = 1 + 1 * 1 = 2 <-- The layout will be double the size of the original
Therefore to completely fill the screen on this device AutoScale should be set as AutoScale(1).

On a device with a resolution of 800 x 1280 this AutoScale rate causes the layout to go partially off the screen.

With a resolution of 800 x 1280 the delta value is:
delta = ((1280 + 800) / (320dip + 430dip) - 1) = ((2080 / 750) -1) = (2.773 - 1) = 1.77
However, working out the 'delta' value for the two parts of the resolution separately it gives the following results:
(1280 / 430) -1 = 1.98
(800 / 320) - 1 = 1.5

Is it the 'delta' value that causes the AutoScaled layouts to spill over the screen on devices with certain resolutions?
If this is the case, can the 'delta' value used by the AutoScale process be adjusted so that the layout is only scaled up using the smallest of the delta values?

Regards

Joe
 

klaus

Expert
Licensed User
Longtime User
The problem is the width / height ratio. If it's the same as the standard layout everything is OK but if it's bigger there are some drawbacks explained in chapter 8.10 AutoScale in the Beginner's Guide.
If you want to play with a factor you should play with the rate factor that's it's purpose.
In most cases streching a small 3.5'' screen up to a 10'' sceen doesn't look really good so you should use a rate vale lower than 1.
You could also have a look at the Autoscale Code Module that has some other equations and allows to autoscale views added in the code.
 
Upvote 0

JdV

Active Member
Licensed User
Longtime User
Klaus

Thanks for the reply. Your AutoScale code module did the trick (though I did have an issue with the font/label size in a spinner's drop down list on an Android 4.0.4 device) however a drawback of doing it in code is that you lose the ability to test the layouts by sending them to the UI cloud.

Is it worth adding a 'wishlist' request for the AutoScaleAll command to be extended to allow for better scaling like in your code module?

Regards

Joe
 
Upvote 0
Top