有时候发现并不能成功,但还是还没发现问题再哪里,先放着。
String url="图片地址“
Glide.with(getActivity())
.download(url)
.into(new SimpleTarget<File>() {
@Override
public void onResourceReady(@android.support.annotation.NonNull File file, @Nullable Transition<? super File> transition) {
try {
Bitmap resource = BitmapFactory.decodeStream(new FileInputStream(file));
if (resource != null) {
byte[] chunk = resource.getNinePatchChunk();
if (chunk != null && NinePatch.isNinePatchChunk(chunk)) {
NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(getContext().getResources(), resource, chunk, new Rect(), null);
peer_rod_iv.setImageDrawable(ninePatchDrawable);
} else {
peer_rod_iv.setImageBitmap(resource);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
});