在 android 图像视图中显示 google 带滑行的驱动器图像
show google drive image with glide in android imageview
我的驱动器 url 是 -
https://drive.google.com/file/d/0B3DFHb2-MdGYa2NMUkVtVkZ1V1k/view?usp=sharing
我想使用滑行在 android imageview 中显示它。我尝试了很多方法来展示它。
以下是我要显示的代码 -
Glide.with(getActivity()).load(readExcelFeed.getImage().toString()).into(ivQueImage);
请让我知道其中有什么问题。
除非我遗漏了什么,否则您只想使用 Glide 显示单个图像。只需右键单击它,select "Copy image address",然后将其用作 Glide 的 url 字符串。
String url = "https://lh3.googleusercontent.com/s6-0yxPhDS4Os7SYbP66RCNp-mDwuKr72mLJx9ekuTWYFPgXahCvj-oVatwXELyVfyZzD80YTaiYde4=w1278-h954-rw";
Glide.with(getActivity()).load(url).into(ivQueImage);
请求图片来源必须使用executeMediaAndDownloadTo()
service.files().get(fileId).executeMediaAndDownloadTo(outputStream);
然后你可以从输出流
中得到byte[]
byte[] data = outputStream.toByteArray();
并将其插入 Glid
RequestOptions options = new RequestOptions();
options.skipMemoryCache(true);
options.diskCacheStrategy(DiskCacheStrategy.NONE);
Glide
.with(this)
.load(data)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
通过 Glide Library Google 将图像加载到 ImageView 的步骤
第 1 步:在您的云端硬盘中,您希望在 ImageView 上显示哪个图像。您需要从 google 驱动器的三个点中获取可共享的 link。像这样“https://drive.google.com/open?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9”
第2步:然后是显示图片的基础url。 link 是
public 静态字符串 BASE_URL = "https://drive.google.com/uc?id=";
第 3 步:在第 1 步中,您会看到图像的 ID,然后将此 ID 添加到基础 URL。喜欢这种类型
“https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9”
第 4 步:使用 Glide 库在 ImageView 上显示图像,如下所示:
Glide.with(mContext)
.load("https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9")
.into(holder.user_image);
现在您可以在 ImageView 上看到您的图像了。
我的驱动器 url 是 - https://drive.google.com/file/d/0B3DFHb2-MdGYa2NMUkVtVkZ1V1k/view?usp=sharing
我想使用滑行在 android imageview 中显示它。我尝试了很多方法来展示它。 以下是我要显示的代码 -
Glide.with(getActivity()).load(readExcelFeed.getImage().toString()).into(ivQueImage);
请让我知道其中有什么问题。
除非我遗漏了什么,否则您只想使用 Glide 显示单个图像。只需右键单击它,select "Copy image address",然后将其用作 Glide 的 url 字符串。
String url = "https://lh3.googleusercontent.com/s6-0yxPhDS4Os7SYbP66RCNp-mDwuKr72mLJx9ekuTWYFPgXahCvj-oVatwXELyVfyZzD80YTaiYde4=w1278-h954-rw";
Glide.with(getActivity()).load(url).into(ivQueImage);
请求图片来源必须使用executeMediaAndDownloadTo()
service.files().get(fileId).executeMediaAndDownloadTo(outputStream);
然后你可以从输出流
中得到byte[]
byte[] data = outputStream.toByteArray();
并将其插入 Glid
RequestOptions options = new RequestOptions();
options.skipMemoryCache(true);
options.diskCacheStrategy(DiskCacheStrategy.NONE);
Glide
.with(this)
.load(data)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
通过 Glide Library Google 将图像加载到 ImageView 的步骤
第 1 步:在您的云端硬盘中,您希望在 ImageView 上显示哪个图像。您需要从 google 驱动器的三个点中获取可共享的 link。像这样“https://drive.google.com/open?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9”
第2步:然后是显示图片的基础url。 link 是 public 静态字符串 BASE_URL = "https://drive.google.com/uc?id=";
第 3 步:在第 1 步中,您会看到图像的 ID,然后将此 ID 添加到基础 URL。喜欢这种类型 “https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9”
第 4 步:使用 Glide 库在 ImageView 上显示图像,如下所示:
Glide.with(mContext)
.load("https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9")
.into(holder.user_image);
现在您可以在 ImageView 上看到您的图像了。