Android从asset中获取drawable

来源:互联网 发布:检查英语语法的软件 编辑:程序博客网 时间:2024/05/16 03:47

Android从asset中获取drawable

public static Drawable assets2Drawable(Context context, String fileName) {    InputStream open = null;    Drawable drawable = null;    try {        open = context.getAssets().open(fileName);        drawable = Drawable.createFromStream(open, null);    } catch (IOException e) {        e.printStackTrace();    } finally {        try {            if (open != null) {                open.close();            }        } catch (IOException e) {            e.printStackTrace();        }    }    return drawable;}
0 0