开发者

A correct name for resources folder

I have a set of drawable resources to use on both large hdpi and xlarge mdpi screens, and I don't want to double them in different folders, so how should I name my folder to make both devices take resources from it. Now I have drawable-mdpi, drawable-hdpi, drawable-large-hdpi and drawable-xlarge-mdpi folders, last two contain the same set. Thanks in advance开发者_StackOverflow中文版.


When you have common set of drawables just put them in drawable folder.


That is actually quite an interesting question. I don't think there is a way of naming that will solve it, as far as i know.

You might be able to come up with a solution by using an alias for your drawables. You can then name all your drawables with unique names and then just create an alias in the different resolution folders, that refers to the correct image.

To create an alias to an existing drawable, use the <bitmap> element. For example:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/icon_ca" />

If you save this file as icon.xml (in an alternative resource directory, such as res/drawable-en-rCA/), it is compiled into a resource that you can 
reference as R.drawable.icon, but is actually an alias for the R.drawable.icon_ca resource (which is saved in res/drawable/).

You can read more at http://developer.android.com/guide/topics/resources/providing-resources.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜