views:

13

answers:

1

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]}}
+2  A: 

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.

CommonsWare
Can u show me an example, how u would do it using <include>? Thank you!
OneWorld
@OneWorld: Here is an article about `<include>`: http://developer.android.com/resources/articles/layout-tricks-reuse.html I would first copy your existing layout to `layout-land`, and make the adjustment so it works the way you want. Then, find the common portions between the two, pull those out into separate layout files and `<include>` them in your two main layout files. You may also wish to use the `<merge>` element: http://developer.android.com/resources/articles/layout-tricks-merge.html
CommonsWare