The AutoScale function in the Designer Scripts scales only views added in the Designer but not views added in the code.
To overcome this drawback I wrote a Scale Code module, the first version is already included in the Desiger Scripts & AutoScale Tutorial.
There are two other drawbacks :
The AutoScale function in the code module scales also the internal views in ScrollViews, ListViews and scales the TextSize property of Spinners.
The Scale code module contains following functions:
Activities:
If you don't need all routines in the Scale module you can remove those not needed.
The Scale module scales also ScrollView2D views, if you don't use such a view you must comment the corresponding lines or remove them.
I think the code is enough self explanatory.
Best regards.
EDIT: 2013.09.27
Added SetReferenceLayout
Added HorizontalScrollView
EDIT: 2014.11.20
Amended error reported HERE.
To overcome this drawback I wrote a Scale Code module, the first version is already included in the Desiger Scripts & AutoScale Tutorial.
There are two other drawbacks :
- the internal Labels of ListViews are not scaled.
- with the Designer Scripts AutoScale function for some smartphone screen sizes especially the 480 x 800 scale 1.5 screen the scaling is not optimal (at least for me).
With AutoScale on a screen with a resolution of 480 x 800 scale 1.5 (the standard screen is 320 x 480 scale 1) the views are stretched too much horizontally and not enough vertically because of the different width/height ratio.
The AutoScale function in the code module scales also the internal views in ScrollViews, ListViews and scales the TextSize property of Spinners.
The Scale code module contains following functions:
- Initialize Calculates the scale factors
- SetRate(Rate) Sets a new Rate value and calculates the scale factors
- ScaleView(View) Scales the given view with its child views
with the new equations. - ScaleViewDS(View) Scales the given view with its child views
with the Designer Scripts equations - ScaleAll(Activity, True) Scales all views of the given Activity or Panel
with the new equations. - ScaleAllDS(Activity, True) Scales all views of the given Activity or Panel
with the Designer Scripts equations - GetDivicePhysicalSize Gets the approximate physical size of the device
- GetScaleDS Returns the Disigner Scripts scale factor
- GetScaleX Returns the X scale factor
- GetScaleX_L Returns the X scale landscape factor
independant of the current orientation - GetScaleX_P Returns the X scale portrait factor
independant of the current orientation - GetScaleY Returns the Y scale factor
- GetScaleY_L Returns the Y scale landscape factor
independant of the current orientation - GetScaleY_P Returns the Y scale portrait factor
independant of the current orientation - Bottom(View) Returns the Bottom coordinate of the View
- Right(View) Returns the Right coordinate of the View
- HorizonzalCenter(View, x1, x2) Centres the View horizontally the view between two coordinates
- HorizonzalCenter2(V1, V2, V3) Centres the View V1 horizontally between two views V2 and V3
- VerticalCenter(View, x1, x2) Centres the View horizontally the view between two coordinates
- VerticalCenter2(V1, V2, V3) Centres the View V1 horizontally between two views V2 and V3
- IsActivity(View) Returns True if the View is an activity
- IsPanel(View) Returns True if the View is a Panel
- SetRight(View, xRight) Sets the Left propety of the view according to the given right coordinate xRight and the views Width property.
- SetBottom(View, yBottom) Sets the Top propety of the view according to the given bottom coordinate yBottom and the views Height property.
- SetLeftAndRight(View, xLeft, xRight) Sets the Left and Width properties of view View according to the xLeft and xRight coordinates.
- SetLeftAndRight2(V1, VL, dxL, VR, dxR) Sets the Left and Width properties of view V1 between the views VL and VR with the given spaces dxL and dxR.
- SetTopAndBottom(View, yTop, yBottom) Sets the Top and Height properties of view View according to the yTop and yBottom coordinates.
- SetTopAndBottom2(V1, VT, dyT, VB, dyB) Sets the Top and Height properties of view V1 between the views VT and VB with the given spaces dyT and dyB.
- SetReferenceLayout(Width, Height, Scale) sets a new layout as the reference layout, allows downscaling. AutoScaleRate has no influence in this case !
Activities:
- Main Main screen with an image and buttons.
- Setup The setup screen from the GPSExample program.
- About An about screen example.
- DBWebView A database table in a WebView with a modified DBUtils version
scaling the table text size. - DBScrollView A database table in a ScrollView.
- Keyboard A keyboard with views added in the code.
- ListView A ListView with the internal Labels and Bitmap scaled.
- Calculator A calculator layout from the RPNCalc project without the functions
scaled with the new equations. - Calculator1 Same as Calculator but scaled with the Designer Scripts equations.
- Positioning Example with the different positioning routines.
- Scale The scaling module
- DBUtils The modified DBUtils module
If you don't need all routines in the Scale module you can remove those not needed.
The Scale module scales also ScrollView2D views, if you don't use such a view you must comment the corresponding lines or remove them.
I think the code is enough self explanatory.
Best regards.
EDIT: 2013.09.27
Added SetReferenceLayout
Added HorizontalScrollView
EDIT: 2014.11.20
Amended error reported HERE.
Attachments
Last edited: