0

I am making my 1st ever android app using android studio,

Everything works correctly except switching between portrait and landscape layouts.

What code do i need to insert and, where to get my app to see the layouts I have made.

Thanks Michael

  • 1
    Are the layouts named the same and is one of them in a directory called `layout-land`? See https://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources – Karakuri Nov 06 '16 at 20:09
  • 1
    duplicate: http://stackoverflow.com/questions/2124046/how-do-i-specify-different-layouts-for-portrait-and-landscape-orientations – Veneet Reddy Nov 06 '16 at 20:33
  • I have the layouts in this folder but still nothing – Michael Hill Nov 07 '16 at 02:15
  • Ensure that your activity's declaration in AndroidManifest.xml doesn't force portrait mode. i.e set `android:screenOrientation="user"` – Veneet Reddy Nov 07 '16 at 11:44
  • Thanks, I think it may also be a screen resolution problem ,or layout problem, the back ground rotates but the buttons I have on the background cram up to the top of the screen and don't all appear. – Michael Hill Nov 07 '16 at 12:35
  • It was as you said , an error with the folders containing the layouts – Michael Hill Nov 07 '16 at 16:36

1 Answers1

2

You have to create a new folder called layout-land and place it in there.

Ex: Your layout's current location is layout/my_layout.xml, you would place the corresponding landscape layout in layout-land/my_layout.xml

Check: http://developer.android.com/guide/practices/screens_support.html under "Using configuration qualifiers"

Similar Question: How do I specify different layouts for portrait and landscape orientations?

Community
  • 1
  • 1
Veneet Reddy
  • 2,707
  • 1
  • 24
  • 40