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?
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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With