如何从assets文件夹中的图像创建drawable?

时间:2014-04-04 05:00:53

标签: android android-drawable

此代码始终返回null

String path = "file:///android_asset/image.png";
Drawable d = null;
try {
     d = Drawable.createFromStream(ContextHolder.getActivity().getAssets().open(path), null);
} catch(Exception e) {

}

2 个答案:

答案 0 :(得分:2)

Drawable d = Drawable.createFromStream(getAssets().open("image.png"), null);

答案 1 :(得分:2)

路径错误

String path = "image.png";