Resourse overwritting warning - android

I always get a resource overwriting warning when I want to create a layout file BUT in different folder (for different configuration). I created a folder in lib directory as layout-port (for portrait orientation) and after right clicking the very same folder,If i wanna create a new file with the name of default xml layout file, it gives me the "file overwriting warning". WHY IS THAT? As far as I know I can use same file name in different resource folder.

I encountered this annoying situation too, it seems that even you selected layout-land to create the new file there, it still defaults to layout, so my workaround is to create the new file with a different name, for example main1.xml. Then I cut/paste the file from layout, into the layout-land.

Related

How does one get dimens.xml (sw600dp) into Android Studio?

I inherited the values folder structure shown below.
For over an hour I've Googled and looked and pulled down menus in Android Studio 1.2.2 and tried creating files and folders but nothing I have done lets me add, for instance, dimens.xml (sw720dp).
I deleted dimens.xml (sw720dp - landscape) because landscape didn't suit my needs.
What steps did whoever created the folder structure take in order to get dimens.xml (sw600dp) to appear in the structure?
What steps do I need to take to get a dimens.xml file with the sw<N>dp file naming convention? How do I get dimens.xml (sw720dp) where it belongs?
You can ignore the rest of this. I'm just showing that I've TRIED stuff, none of which works right.
Am I supposed to right-click values or dimens.xml (2)? What then?
Here's what I did and it didn't do as I need:
I also tried:
EDIT
I also tried copying the sw600dp file. No luck:
IT CAN'T BE THIS HARD.
What steps do I need to take to get a dimens.xml file with the swdp file naming convention?
First, you will probably be happier with life if you change the drop-down above your project tree from "Android" to "Project", which shows you an actual filesystem view of your project.
To add a resource directory from within Android Studio:
Right-click over res/
Choose New > "Android resource directory" from the context menu to bring up the New Resource Directory dialog:
Choose your resource type in the "Resource type" drop-down (in this case, values)
Click on your desired qualifier (in this case, "Smallest screen width") in the "Available qualifiers" list.
Click the >> button
In the field that appears, fill in your numeric value (in this case, 600)
Click OK to close the dialog and create the directory
To add dimens.xml to that directory, right-click over the newly-created directory and choose New > "Values resource file" from the context menu.
I have had MANY failures trying to do stuff OUTSIDE Android Studio, but this time I got away with it:
I will now see how #Commonsware says I could have done it.
EDIT
And as always, #Commonsware bailed me out with good advice (I have no idea when or why or how I lost the File structure "tab" along the left margin).
Here's what I now see, and (I was right:) it's NOT hard to see what to do ONCE YOU SEE THIS:
And, following his advice, I get to here and am ready to create the dimens.xml file that goes inside:

Android Studio - layout-land folder not appearing

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:
Right Click on res folder and create a new directory
Give name - 'layout-land'
Problem is- the created folder is not appearing within res folder :(
I am clueless, please suggest.
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.
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).
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.

How to detect device/emulator layout (landscape/portrait) is changed

Duplicate of this.
I am not able to add comment to the existing question that's why I have ask new question.
There is one solution in the above question "if your Android device is in landscape mode and you are loading a layout the android system will look if this layout file exists in the /res/layout-land folder. If it does not exist in this folder it will load the layout from the normal /res/layout folder."
But some how it is not working for me. I have added folder called land in layout folder also added xml file with same name, but it is still loading xml file from the main layout folder , when my screen is in landscape mode.
Is there any other solution ?
Here is the link of the answer.
It just has to do with SDK version(11 and 13).

Android get a res folder to show under resource type

I created a folder under res/xml. When I create a new xml file, xml does not show under resource type like the other resources under res. How can I make it appear?
Edit: I am using eclipse
If you mean the Dialog in eclipse with the Resource Type dropdown then know it's a static predefined dropdown. It won't have all possibilities or any special setup you are trying to achieve. You can simply create an xml file in the folder without having to drag it there.
Try create your xml inside layout folder and use R.layout.YourLayoutName and it should appear successfully

Multiple layers of folder inside the layout

In my android project, I have a folder called layout to store all xml files for layout, but there is also a folder inside called layout_settings
layout---->layout_settings--->about.xml
In my code
I have setContentView(R.XX.about). How do I set it such that reflect the about.xml inside layout_settings folder.
The reason I am doing is I don't want to scatter all the layout files into flat hierarchy.
No, you can't configure or modify a folder structure in android packages res/layout because they are read only file system.
The resources mechanism doesn't support subfolders in the layout directory, so you need to keep that hierarchy flat.
If you have to do like that just you can give a xml files name like, layout_setting.xml , layout_display.xml etc and use it.

Categories

Resources