问题
My drive url is - https://drive.google.com/file/d/0B3DFHb2-MdGYa2NMUkVtVkZ1V1k/view?usp=sharing
I want to show it in android imageview using glide. I have tried many ways to show it. Following is my code to show -
Glide.with(getActivity()).load(readExcelFeed.getImage().toString()).into(ivQueImage);
Please let me know what is the issue in it.
回答1:
Unless I'm missing something, you want to show just that single image using Glide. Just right click on it, select "Copy image address", then use that as your url String for Glide.
String url = "https://lh3.googleusercontent.com/s6-0yxPhDS4Os7SYbP66RCNp-mDwuKr72mLJx9ekuTWYFPgXahCvj-oVatwXELyVfyZzD80YTaiYde4=w1278-h954-rw";
Glide.with(getActivity()).load(url).into(ivQueImage);
回答2:
For request image source you must use executeMediaAndDownloadTo()
service.files().get(fileId).executeMediaAndDownloadTo(outputStream);
Then you can get byte[]
from output stream
byte[] data = outputStream.toByteArray();
and insert it to Glid
RequestOptions options = new RequestOptions();
options.skipMemoryCache(true);
options.diskCacheStrategy(DiskCacheStrategy.NONE);
Glide
.with(this)
.load(data)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
来源:https://stackoverflow.com/questions/42453328/show-google-drive-image-with-glide-in-android-imageview