Android Studio create another layout folder - android

In Android Studio, besides the default layout folder, I need to create layout-land for different layout in landscape mode. However I couldn't add a new folder. I've tried some ways such as right click -> new -> Directory, right click -> new -> Android resource directory, right click -> new -> Folder but all of them didn't work at all. What is the appropriate way to create a new layout folder?

On the left on Android studio there where you can see all your classes and packages you can see on top a selector. try altering that selector to show Project rather than your app if this is the situation.
Sometimes when you show only app contents resource folders are somehow hidden when they are empty but when you switch to project view most of the times are visible.

Right click on layout folder -> New -> Layout resource file
Choose Orientation in bottom frame and select Landscape

Related

layout already exists use a different qualifier

i'm trying to support screens size by create each layouts on Android Studio 3.1.3
i use the following steps to create one xml for example XXXHDPI :
Preview > Orientation for Preview > Create Other > Density and from Density i choose XXXHDPI ,the layout-xxxhdpi of my Activity will created.
but Android Studio 3.2 i can't do that when i try to create layout i get this message :
layout already exists use a different qualifier
Make sure you are following these steps:
Right click on res folder=> New => Android Resource directory => Then
a dialog appear => Resource type from dropdown => select layout => and
from qualifier => click on density => >> => then your desired density
Or you can do(This will definitely work)
Create folder by yourself
right click on res=> show in explorer=> under res folder=> create a
new folder=> rename it to => layout-xxxhdpi
If you checked the directory of res/layout-xxxhdpi and it wasn't there so probably that might be a bug. But, you can however try to add the directory manually.
Just go to /res folder of your project and add a new folder called layout-xxxhdpi.
Please use issue tracker or, report a bug of the Android Studio by clicking on the Help -> Report a bug if you insist that it does not exist in there.
Read: https://developer.android.com/studio/report-bugs#studio-bugs
You can create in explorer. For first activity you can create in android studio. But for other activities you can use this steps:
right click on activity that u want to create large or x-large activity
show in explorer
copy xml file
go to main/res/large-layout in explorer and paste it then close explore.
It works successfully and large activity will appear in android studio.

I want to use qulifier <large> in android studio,but I can't add the directory layout-large

I am a fresher in android.In my tutorial book(
A little outdated) teaching in Eclipse,It just add a directory layout-large to code another layout xml files to adapt big screen.
I use android studio,when I add the directory,it says:
and add the layout-largedirectory:
I am wondering if there is a different way to use qulifier to adapt big screen in adroid studio?
You can try adding the folder in the /res directory using your file explorer.
Or you can try switching to Project view in stead of Android to do this inside Android Studio as visible in this screenshot:
When in project view all different resource folders are visible in your IDE, while in Android view, these get visualized in what appears to be a single folder.
Once you see this, you can right-click on the res folder and select new>Android Resource Directory
There you can add different types of resource paramater to new folders.
These resource parameters can be for Locale, density or as in your case screen size.
Switch your Project view with option "Project" not for "Android" you will see the folder.

Android Studio: Newly Created Directory Not Appearing In Folders View

I am trying to create a new folder inside the /res directory
I added a new directory
The folder does not appear in the /res folder even though it exists in the finder
Case and point I tried adding the folder again and I got a message telling me it exists.
If you can suggest what I can do to fix this I'd love it!
(And yes I have restarted the program as well as my computer)
Turns out there is a selector at the top which, by default, is set to show Android. If you flick the toggle down to 'Packages' you can see your own packages.
In Android Studio you can add new directories by right clicking the resource folder in the Android view. (Don't get confused by the New Directory option.)
For example, if you want a new layout resource file and folder then right click layout and choose New > Layout resource file.
If you want a new layout-sw600dp for the activity_main.xml file then choose Smallest Screen Width from the list and click the >> button. Fill in the file name and width and click ok.
Android Studio will automatically create the layout-sw600dp directory and in the Android view you will have both layout files conveniently displayed next to each other.
It is a similar process for adding other resource directories and files (see my other example).
Clicking at TAB Android in top, select the perspective Project Files. Then u can see all folders of project.
Android 4.0
The Android view by default seems to conceal the duplicated resource type directories in the side panel.
If you want to view the duplicate resource type directories i.e. drawable for two different languages,
switch the view from "Android" to "Packages" or "Project" or "Project Files"
Browse the actual folder structure in windows and you'll see the folder. Put the same resource file found in the normal drawable folder into this new directory. Then when you go back into Android Studio you'll now see 2 files under the NORMAL \res\drawable structure. Make sure you don't look for a subfolder in Android Studio called "drawable-sw600dp" because you won't find it other than in windows explorer. What you will find in Android Studio (after you copy the resource file) is a new resource file along with your original called "jenny-web.png (sw600dp)" or something similar. This same principle resolves the same error when working with other resources like layouts.
For Android Studio 3.0, those who are following https://developer.android.com/training/basics/supporting-devices/languages.html and have encountered the same issue as the one stated in this question, you can also do the following aside from the above answers which are helpful.
Right click to the target folder (i.e. res folder) > New
Choose Android Resource File
Specify the file name, and in the Directory name field put the folder name you want to create or the existing folder you want to put the resource file.
After hitting OK, in the Project files dropdown, you will see the correct strucutre.
And in the Android dropdown, you will see it as part of the strings.xml under values folder.
This worked best for me. What I did was I right-clicked the 'app' directory and chose 'New' >> 'Android Resource File'. After that I filled in the File Name with 'strings'. Chose 'XML' as my resource type and my Directory Name was 'values-b+za+ZA'.
This created everything as I wanted it to, however, values-b+za+ZA, still didn't show in the Android view but it shows in the Package view. (The views you choose from the top dropdown.)
The difference this time is that in the Package view I can still see my new 'strings.xml' file and in the Android view I van also see the new 'strings.xml' file.
I guess android studio doesn't show custom directories in the Android view but creates like some kind of link to the true directory when working with it. I am not familiar with Android Studio at all but this did work for me. If there are more professional answers please feel free to correct me.
You most probably have the file named in Uppercase, Android Studio does not recognize file names in Uppercase, I had made this mistake a while back.
As the developer doc states:
be sure the Project window is open (select View > Tool Windows > Project)
and the Android view is selected from the drop-down list at the top of that window.
You will then be able to see all relevant project files (including new ones) in a more efficient way.
Hope it helps someone.
This is odd but in my case i had to many underscores delimiters.
When i renamed yt_search_view (2 delimiters) to yt_searchview (1 delimiter), it appear in project view where it should be. It is probably a bug. My version is Android Studio 3.2.
Also, i notice that if i add a value folder to the layout folder, it also fix the issue.
Example:
layout_control_x
--layout
----top_panel.xml
--values <--adding this empty folder fixed the problem
For complete information on how to add sub folder layouts check this.

Eclipse - how to create a new project with drag 'n' drop controls capability

I'm watching a video from Google I/O on a way to create an android app by dragging and dropping elements onto the eclipse window. Example: if you want a button, you just drag a button onto the screen.
http://www.youtube.com/watch?v=Oq05KqjXTvs # 0:07:25
I've downloaded JDK, Android SDK, and the ADT Plugin, but, I cannot figure out how to get to the place where I can drag 'n' drop controls into my app. In Eclipse, after configuring the ADT Plugin, I went to File -> New -> Project -> Android Project, and I do not see a panel on the left with a list of controls.
Am I missing something? Thanks.
You can only drag and drop on to layout files (.xml). Now that you have created a new project, you will have automatically created the default main.xml. This will be in the res\layout folder as shown in the project explorer view. If you click on that you will get two tabs for editing it, one is plain text, the other is the graphical view - this is where you drag widgets to.
The screen that you referred to is what you see when you work with the layout file. Create a new class and create a layout for it. Select the layout then you can drag and drop.
Havent seen the video , but after you create a project you will have to go to res->layout->click on xml file. The editor for xml file has a tab called graphical Layout. You can drag and drop controls in this editor

A new xml file in drawable_hdpi

I want to create one new xml file in the drawable_hdpi folder, but the new file doesn't appears in the drawable_hdpi folder, it appears in the layout folder. Can you tell me why?
In SDK 1.6 it is OK, but in SDK 2.2 it is not.
edit:for example in the app res/drawable_hdpi choice the drawable_hdpi folder,then right-hand button create new android xml as foo.xml,but the xml is created at the layout_hdpi folder
not at the rawable_hdpi folder
My guess is that you are trying to create a new "Android XML" file in Eclipse by right-clicking on your drawable_hdpi folder. I am able to duplicate the problem you are having. The dialog that pops up when you try to do this can dictate where the file gets created based on various setting within.
I tried to embed and image here to show you but SO wouldn't let me. Sorry.
The radio buttons will change the folder list beneath the "Available Qualifiers" list will change depending on which button you select. For whatever reason, there is no radio button for drawable. If you try to edit the folder by hand, your radio button selection disappears and the finish button disables, so you can't even force it to do what you want.
Really you should just copy an xml file similar to what you want to your drawable_hdpi folder manually outside of eclipse. Afterwards, just do a refresh on your res folder in Eclipse and the file will show up there. Then you should be able to edit it within Eclipse.
Hope that helps,
Craig

Categories

Resources