show google drive image with glide in android imageview

故事扮演 提交于 2019-12-02 23:12:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!