Question

I just want to group 4 buttons like this...

Portrait mode:

[1][2]
[3][4]

Landscape mode:

[1][2][3][4]

I dont want to hardcopy my Portrait mode xml-File and put it into the "layout-land" folder for this minor difference. Then, I have to modify two file when implementing new stuff.

Isnt that achievable through wraping it up intelligently in some LinearLayouts? Something like this? ({} represent LinearLayouts)

{{[1][2]}{[3][4]}}
Was it helpful?

Solution

Isnt that achievable through wraping it up intelligently in some LinearLayouts?

Not automatically. You would still need to dynamically change the outer LinearLayout between vertical and horizontal orientation. You can perhaps do that in your onConfigurationChanged() method.

Another option would be to have layouts in res/layout and res/layout-land, but use the <include> directive, so your buttons are defined once but are imported into their proper spots.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top