📜  java将url图像转换为drawable - Java代码示例

📅  最后修改于: 2022-03-11 14:52:09.244000             🧑  作者: Mango

代码示例1
public static Drawable drawableFromUrl(String url) throws IOException {
    Bitmap x;

    HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
    connection.connect();
    InputStream input = connection.getInputStream();

    x = BitmapFactory.decodeStream(input);
    return new BitmapDrawable(Resources.getSystem(), x);
}