android - 从 Firebase 存储设置 imageView
问题描述
鉴于我已经拥有用户上传图像的 url,如何直接从 Firebase 将图像设置为 imageView?
解决方案
如果您在客户端有可用的图像 URL。实现 GLIDE并将 URL 和 ImageView 传递给 Glide。它将负责向客户显示图像。
ImageView imageView = findViewById(R.id.imageView_ID);
RequestOptions requestOption = new RequestOptions()
.placeholder(R.drawable.placeholder)
.error(R.drawable.ic_error_1)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.dontAnimate()
.dontTransform()
new Glide
.with(mcontext)
.load("https://placeholder.com/img/products/imageurl.png")
.apply(requestOption)
.thumbnail(0.1f)
.into(imageView)
添加依赖实现 'com.github.bumptech.glide:glide:4.8.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
推荐阅读
- macos - 如何通过命令行 (macOS) 复制(或查看)当前目录/文件夹的名称
- java - 需要通用方法来读取 csv 文件
- laravel-5 - 拉拉维尔 | 提交后获取下拉选择的值
- xamarin.forms - Xamarin 形式的 Emojis 不能在移动端工作?
- javascript - 如何将当前用户 ID 与 firebase 数据库数据的值相匹配?
- java - 如何使用 [Apache POI] 创建依赖下拉列表
- css - masonry - 如果页面调整大小,则在一列中显示图像
- docker - 如何将本地镜像推送和部署到 Kubernetes
- c - 如何修复“Gtk-WARNING ** 使用标题栏添加到对话框操作区域的内容”
- c# - 使用 Fopen 读取 C 中的文件并从中获取特定值