2011-05-24 94 views
0

我有一组可绘制的资源可用于大型hdpi和xlarge mdpi屏幕,并且我不想将它们放在不同的文件夹中,所以应该如何命名我的文件夹才能使设备从中获取资源。现在我有drawable-mdpi,drawable-hdpi,drawable-large-hdpi和drawable-xlarge-mdpi文件夹,最后两个包含相同的集合。提前致谢。资源文件夹的正确名称

回答

2

当你有一组常用的drawable时,只需将它们放在drawable文件夹中即可。

+0

其实我有三套,请阅读我的问题仔细 – Egor 2011-05-24 14:56:02

+0

如果您在清单的Android添加屏幕支持将绘制从'drawable'文件夹,如果它没有找到任何可绘制的任何drawable-mdpi,drawable-hdpi,drawable-large-hdpi文件夹, – 2011-05-24 15:34:08

+0

我明白了,一个好主意,谢谢! – Egor 2011-05-24 16:46:45

1

这实际上是一个非常有趣的问题。就我所知,我不认为有一种方法可以解决它。

您可以通过为绘图使用别名来提出解决方案。然后,您可以使用唯一的名称命名所有可绘制对象,然后在不同的分辨率文件夹中创建一个别名,它指向正确的图像。

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/). 

你可以阅读更多的 http://developer.android.com/guide/topics/resources/providing-resources.html

相关问题