Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create new res folder in Android Studio

Tags:

I want to add localized strings for my android app. Therefore I need a values-xx folder in my Res folder.

The original values folder has a blue dot, so I tried creating a new Package, but a package can't contain a hyphen so this must be wrong. Instead I tried right-clicking res and choosing New -> Android resource directory, but this time nothing happens. No dialog or reaction of any sort as I can see.

How do I create a values-xx folder?

Edit: I can create the folder from file explorer and it all works good. It is just irritating to not be able to do it from inside Android Studio.

Edit2: This bug is fixed in newer versions of Android Studio.

like image 387
Moberg Avatar asked Jun 17 '13 11:06

Moberg


People also ask

How do I create a folder in Android Studio?

In the drop down menu click on the new option. After this a drop down menu opens here you will see directory option just click on that. After this enter the name of your directory / folder and press enter this will create a new folder / directory inside your root folder.

What is res folder in Android Studio?

The res/values folder is used to store the values for the resources that are used in many Android projects to include features of color, styles, dimensions etc.

How do you make res?

Lets break it stepwise:- 1) Open your project 2) Right click the res folder 3) Choose New 4) Chose Directory 5) Name the directory. Thats it!!


2 Answers

When you are in the Android view (rather than Project or Packages) in Android studio, you just need to right click the "values" directory and choose New > "Values resource file".

enter image description here

That gives you a chose of different resources you can add. For example, if you want to add a different language to your app you can choose the Language option and press the ">>" button. If you want Swahili then select that from the list, type "strings" for the file name, and press OK.

enter image description here

Android Studio will automatically create a values-sw directory with the new strings.xml file in it. And in your Android file view you conveniently see both strings files together.

enter image description here

And it is a similar process for adding other types of resources (see my other example). You no longer have to manually add the directories (but you can do that too by right clicking the res directory and choosing New > Android resource directory).

like image 117
Suragch Avatar answered Sep 19 '22 11:09

Suragch


I had the same problem, what I did was create a values-xx folder inside the main directory (main>>right click>>new>>directory) and then moved that folder to res/ directory.

It's not beautiful but it is a workaround to create a folder with Android studio.

like image 34
rafaello Avatar answered Sep 20 '22 11:09

rafaello