从外部包访问Android资源

时间:2011-08-24 16:53:11

标签: android drawable

我想将外部包中的可绘制图像读入位图。例如,在com.test.images包中,我在drawable-hdpi文件夹下有一个名为image1.png的图像。我想将该图像从另一个包中读入Bitmap对象,例如com.test.reader。有人可以给出解决方案吗?

我可以使用getResourcesForApplication(packageName)来访问外部包的资源,但是我得到的资源对象只有一个getDrawable方法;我想为图像获取一个位图。

由于

1 个答案:

答案 0 :(得分:0)

获得Drawable对象后,您必须将其转换为Bitmap对象。

Refer to this question看到一种可能的方法来实现这一目标。