-3

I am a new android developer . I want to add two XML files. One for portrait screen and another for landscape. Can someone please give some steps to solve this problem?

A.Turner
  • 196
  • 1
  • 13

3 Answers3

0

You Add into the Manifest file

 <activity
    android:name="YourActivity"
    android:configChanges="orientation"
    android:label="@string/app_name"
    android:windowSoftInputMode="stateVisible|adjustPan" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
Harshit Trivedi
  • 764
  • 9
  • 33
  • its not working @Harshit Trivedi – Karnesh_Prabhu Aug 11 '17 at 09:15
  • this is just not an answer to the question. you should provide some information on how to use the layout xml files. this only configures the activities behavior on orientation changes (restart activity or not). – dedda1994 Aug 11 '17 at 09:20
0

you can make different layout folders for landscape and portrait XML layouts.

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43
0

Follow these steps

1) create a folder called layout-Land under the res folder.

2)copy all landscape xml files to that layout-Land folder with the same name.

3)Make this change to your manifest for that activity

android:configChanges="orientation"

<activity
    android:name=".LoginActivity"
    android:configChanges="orientation"
    android:label="@string/app_name"
    android:windowSoftInputMode="stateVisible|adjustPan" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
Puneet Verma
  • 1,373
  • 2
  • 19
  • 23