PDA

View Full Version : [SOLVED] Dynamically Changing Panel Layout Type



kgmoney
25 Oct 2010, 9:21 AM
Hi,

I'm trying to create an app that changes it's layout based on the device's orientation. So, when it's landscape it would use an HBox and when it's portrait it would use a VBox. Currently I'm trying to use a fullscreen panel with the orientationchange listener that on change, removes all children from the panel and rebuilds it with the right layout.

So far this is not working out well and I was wondering if anyone else knew of a better (probably more correct) way of doing this.

Thanks,
Kevin

kgmoney
25 Oct 2010, 1:59 PM
It seems like something somebody would have done before...anybody?

dbottillo
26 Oct 2010, 12:14 AM
i think that there are at least two methods for manage orientation:

- remove all items from panel and re-add items in the right way (pay attention to add again a component you have removed! you don't have to destroy an item when you remove it)
- have a panel with card layout, in the first card a panel for a portrait and in second card a panel for a landscape, when it orientation change switch between the panels

Plastic
26 Oct 2010, 7:19 AM
i think that there are at least two methods for manage orientation:

- remove all items from panel and re-add items in the right way (pay attention to add again a component you have removed! you don't have to destroy an item when you remove it)
- have a panel with card layout, in the first card a panel for a portrait and in second card a panel for a landscape, when it orientation change switch between the panels

The second one worked for me... Add an orientationChange function called back by an onWindowResize event and show/hide panels you need showed/hidden on every orientation change.

PS: don't forget to add a doComponentLayout() at the end of the orientationChange function.

kgmoney
26 Oct 2010, 10:00 AM
Ah, yes, I hadn't thought about having multiple cards...I like that one, I'll try it.

Thanks!