a simple way i resize all my views created in designer to all screen size is like this
i create the game/app in designer with variant 320x480 (iphone4) and with this code all devices screen size should work, if you are changing views location/size in code then use allways % of x/y !!
like: img1.height = 8%y
img1.width = 10%x
or game speed: dim speed as float = 0.8%y
regards, ilan
EDIT: very importent thing to do is to delete this line in the Designer Script "'AutoScaleAll"
if not it wont work correctly....
B4X:
Private Sub Page1_Resize(Width As Int, Height As Int)
'////// Start resize all views to fit all screensize //////
'start rexize all views
Dim ratiox As Float = Width/320 'iphone 4 3.5" = x320
Dim ratioy As Float = Height/460 'iphone 4 3.5" = y480 - 20 !
For Each v As View In Page1.RootPanel.GetAllViewsRecursive
If Not(v.Tag = "drm") Then 'drm = dont resize me...
v.Width = v.Width*ratiox
v.Height = v.Height*ratioy
v.Left = v.Left*ratiox
v.Top = v.Top*ratioy
End If
Next
'////// End resize all views ///////
End Sub
i create the game/app in designer with variant 320x480 (iphone4) and with this code all devices screen size should work, if you are changing views location/size in code then use allways % of x/y !!
like: img1.height = 8%y
img1.width = 10%x
or game speed: dim speed as float = 0.8%y
regards, ilan
EDIT: very importent thing to do is to delete this line in the Designer Script "'AutoScaleAll"
if not it wont work correctly....
Last edited: