Runtime layout

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have Created a layout with 600 X 1024.Can I Change the position of all view that fit on 480 X 800 in runtime (i.e) dynamically change the position depends upon screen size.pls advise and post the example code
 

Cableguy

Expert
Licensed User
Longtime User
Check the Activity.width value on Activity.Resume and set the views position according to that value returned... Something like:

B4X:
Sub Activity_Resume
Select Activity.Width ' Or Height, wich is easier for you
Case 320 '320x480 screen
 'position the views here
Case 480 '480x800 screen
'position the views here
......

End Select
End Sub
You should also take into attencion that resume is called also when the device is rotated, so you should as well test for that...like:
B4X:
Case 480
If Activity.Height =800 Then ' this is a 480x800 in portrait
'position the views
Else ' this is in landscape
'position the views
End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…