Xojo on Android allows you to view the layout in Portrait or Landscape orientation. It also allows you to lock the orientation so as to force the user to use the App only in one direction.
It would be very convenient to be able to manage two layouts instead of just one, like you can do in Andorid Studio.
For now the only solution I have found is to use the Screen’s “OrientationChanged” event, which changes all the positions, dimensions and locks of all the objects via code.
In future releases, will Xojo add the ability to manage multiple layouts for the same Screen?
Or, are there already faster solutions than write manually coding on the event?
At the outset, Geoff had indicated that the constraints would be dealt with later on Android (ditto for the tablet layout), but that, for the time being, we were operating on Android in much the same way as on desktop targets, with locking. Maybe it would be good to have a roadmap for Android.
That must make life very difficult. Mobile is very difficult without auto layout and constraints as you have to design not only for each orientation but also differing size screens.
The difference is that we control the size of our windows on Desktop. And on mobile, every time an app wake up on a new device it’s landing on a alien world of unknown dimensions and resolutions and the app need to adapt fluidly its interface for the best design for such format the dev can’t limit it. Having rules for the layouts to adapt without extra manual coding would be the best productive way for the devs.
I heard something different at the London conference last year.
Control locking is coming to iOS and there are no plans for supporting constraints on Android.
I did some tests and the OrientationChanged event is not a solution either.
The width/height are not changed so you don’t know if orientation is portrait or landscape.
One can not assume that the app always starts in portrait…
In iOS at least the event tells you what is the new orientation…
I’m afraid Android will stay in alpha for awhile.
At the “OrientationChanged” event you can check the orientation like this:
If System.Device.Orientation = System.DeviceData.Orientations.LandscapeLeft _
or System.Device.Orientation = System.DeviceData.Orientations.LandscapeRight _
Then
'### LANDSCAPE ###
return
End If
If System.Device.Orientation = System.DeviceData.Orientations.Portrait _
or System.Device.Orientation = System.DeviceData.Orientations.PortraitUpsideDown _
Then
'### PORTRAIT ###
return
End If
You can then move and resize the controls.
However, this is not a good solution if you have many controls in your Screen.