主要由两种方法:
1、不把图片放在res/drawable下,而是存放在src某个package中(如:com.drawable.resource),这种情况下的调用方法为:
String path = "com/drawable/resource/imageName.png"; InputStream is = getClassLoader().getResourceAsStream(path); Drawable.createFromStream(is, "src");
int resID = getResources().getIdentifier("imageName", "drawable", "com.test.image"); Drawable image = getResources().getDrawable(resID);
原文地址:http://blog.csdn.net/anjon520/article/details/38024499