Double Layout for Landscape and Portrait

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?



You may be able to create a single layout that re-organises based on constraints, I know iOS supports them, I’m not sure about Android:

Ian, please stop sending this video every time, it doesn’t work like that on Android.

1 Like

But Android has Constraint Layouts and it is the main used one.

If Xojo is not ready for it yet, it should.

Constraint Layouts in Android:

Yes, I was of course talking about Xojo Android.

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. :man_shrugging:

1 Like

From the roadmap:

5 Control Locking for iOS
Making iOS controls lock the way all other project types do.

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.

@StefanA We’re talking about Android, not iOS.

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 _
  '### LANDSCAPE ###
End If

If System.Device.Orientation = System.DeviceData.Orientations.Portrait _
  or System.Device.Orientation = System.DeviceData.Orientations.PortraitUpsideDown _
  '### PORTRAIT ###
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.

I don’t think that it will be different for Android.
It is more likely to be standardized for all platforms just as they will soon do for iOS.