Search code examples
androidandroid-layoutgravitylandscape-portrait

How to maintain the layout when switching between landscape and portrait mode?


I need to use my application in both landscape and portrait modes. So i have made two layouts for both modes in two folders folder-layout and folder-layout-land. Now when i turn the phone the layout is switching good but the same layout in landscape mode is not maintained when switching to portrait mode. Some other different layout is getting loaded.

Is there any solution for this. Please share. Thanks in advance.


Solution

  • As you have done everything right to make 2 xml and keep int 2 folders.

    i think you just need to write this with your activity declaration in Manifest

    android:configChanges="orientation|keyboardHidden"
    

    to handle to configuaration change