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:

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
Cookies are required to use this site. You must accept them to continue using the site. Learn more…