Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization and drawables

I want to localize an image by adding the folder res/drawable-hdpi-no, but I get an error stating "invalid resource directory name". What's up with this?

like image 592
Espen Avatar asked Dec 14 '10 17:12

Espen


People also ask

What do you mean by Drawables?

A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.

What is Android studio localization?

In order to make your application more interactive, your application should handle text,numbers,files e.t.c in ways appropriate to the locales where your application will be used. The way of changing string into different languages is called as localization.

How do you add Drawables?

Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import. Figure 3: Select Import Drawables from the dropdown menu.

What is the preferred image format for Drawables?

Supported file types are PNG (preferred), JPG (acceptable), and GIF (discouraged). App icons, logos, and other graphics, such as those used in games, are well suited for this technique.


2 Answers

As far as I remember, only certain res folders will work. You need to call it drawable-[language code]-r[capitalised localisation code] if I remember rightly. Pretty sure it's one of the Android Tutorials.

Yeah here it is http://developer.android.com/resources/tutorials/localization/index.html

like image 107
AaronM Avatar answered Sep 29 '22 11:09

AaronM


Each Android resource can have configuration parts in its resource name. For example you might have a plain image on

res/drawable 

and a image for a high DPI screen on

res/drawable-hdpi 

Here hdpi is a Screen pixel density configration. A list of supported Android resource configurtions can be found from here

http://developer.android.com/guide/topics/resources/providing-resources.html

The order of configurations are important. They must be on specific order. Your original Norwegian language configuration is on a wrong place. Change

res/drawable-hdpi-no 

to

res/drawable-no-hdpi 

and it works.

like image 34
Jaska Avatar answered Sep 29 '22 09:09

Jaska