Question

I've got a chain of three text views next to one another so that in landscape mode they all align perfectly, however when I rotate to portrait mode they still try to align horizontal although I would like them to align one below another so that they fit on screen. I've tried getting the screen orientation and setting the LinearLayout that contains the 3 text views orientation on screen orientation change but to no avail. Any pointers?

Was it helpful?

Solution

You can create different layout for different orientations. Assuming you have main.xml. Just place it under two folders layout and layout-land, but with one difference: in first one make your LinearLayout vertical, in second one - horizontal. Your app will be automatically switch them when orientation change event occurs.

OTHER TIPS

Just use a different layout for portrait mode.

res/layout-land/yourLayout.xml will be used for landscape mode, res/layout/yourLayout.xml for the portrait, name the files and the views inside the same and the right layout will be inflated on orientation change.

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