23

I want to support separate UIs for both portrait and landscape mode in my android studio project, for which I need to have a folder with name - 'layout-land', to create it I followed below steps:

  1. Right Click on res folder and create a new directory

Creating new layout-land dir

  1. Give name - 'layout-land'

assigning layout-land name

Problem is- the created folder is not appearing within res folder :(

layout-land not visible

I am clueless, please suggest.

1
  • changing to "Project Files" worked for me, but the folder layout-land didn't appear until I manually added some xml file there. (Manually I mean from windows explorer and not from android studio). So I'm still confused, I guess there should be a better way
    – Natalie
    Commented Apr 10, 2017 at 6:22

2 Answers 2

51

That's the slightly confusing 'android' view of Android Studio. It shows only one layout folder (also shows only one drawable folder) which really contains all folders. Switch the view to 'project' and you'll see all folders.

enter image description here

2
  • 2
    Great. This is so annoying and freaked me out. I see this as a bug since you add the file in a different view and it does not change to that view.
    – Joop
    Commented May 12, 2015 at 14:36
  • but i cant do that then .. R.layout.layout2.fragment .. what can i do in this case ? Commented Jul 13, 2017 at 9:29
6

I'm posting this just in case anyone really likes Android hirearchy of the project (note: other answers using classic hirearchy are correct as well).

All layout dirs with different qualifiers are categorized under name "layout". Just right click on the "layout" create your xml with any qualifier you need and you'll get this hirearchy (image below).

All layout dirs categorized under "layout".

Notice activity_main.xml is not a directorty but a category collecting all activity_main.xml files with different qualifiers.

This categorizing pattern appears quite often in Android hirearchy.

1
  • I'm having trouble with your solution. So, 1- I click new under layout 2- I do this ? i.imgur.com/OvQlAcS.png 3- ???
    – Suhaib
    Commented Jul 4, 2017 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.