滑翔与setter方法URL图像源
问题描述:
我想设置图像属性的值对象类,你会在下面,但使用滑翔滑翔与setter方法URL图像源
try {
InputStream stream = new URL("my url").openStream();
Bitmap pictureBitmap = BitmapFactory.decodeStream(stream);
"my model class".setImageBitmap(pictureBitmap);
} catch (IOException e) {
e.printStackTrace();;
}
我想这是你如何获取从图像利用Glide作为位图
Glide
.with(getContext())
.load("my url")
.asBitmap()....
答
网址源可以在使用SimpleTarget作为参数传入方法。它会加载你的位图,你可以在图像准备好后将它放入你的图像模型中。
Glide
.with(getApplicationContext())
.load(IMAGE_URL)
.asBitmap()
.into(new SimpleTarget<Bitmap>(100,100) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
YourModelClass.setImageBitmap(resource);
}
});
那么,你的问题到底是什么? – ikhsan
@ikhsan使用Glide完成代码设置图像属性 – Geob
检查我的答案 – ikhsan