Android从asset中获取drawable

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;
}

你可能感兴趣的:(android,android,string)