Skip to content Skip to sidebar Skip to footer

How To Dynamically Change Linearlayout Orientation Depending On Device Orientation

How do I change the orientation of a LinearLayout when a device changes orientation? What changes would be needed in the *.xml's associated *.kt file? For example, the device is in

Solution 1:

You need to use separate folders for your layouts : layout for portrait mode and layout-land for landscape mode, and put two separate xml files with the same name in each one.

One of xml files with LinearLayout with a vertical orientation and another xml file with LinearLayout with horizontal orientation.

For instance look at How to Add/Create Landscape Layout in Android Studio

Post a Comment for "How To Dynamically Change Linearlayout Orientation Depending On Device Orientation"