从firebase存储下载图像
我正在开发一个使用firebase的应用程序,该应用程序使用滑动将图像从firebase存储读取到listview中。 你知道什么是下载图像到列表视图项目的最佳方式?从firebase存储下载图像
如果你正在使用滑动,你可以用它来填充ListView中的ImageView。 Glide有方法into
例如
final ImageView myImageView;
Glide
.with(myFragment)
.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.crossFade()
.into(myImageView);
我不跟火力地堡贮存熟悉,但我想,当你上传图片到这个平台上,他们给你以访问该资源的URL。好吧,如果这是正确的,试试这个代码在你的适配器类为ListView:
ImageView img = (ImagenView)findViewbyid(R.id.myimageview);
String url = "http://..."; //Firebase URL to the picture
Glide.with(yourActivity).load(url).into(img);
不要忘了修改与滑翔路gradle这个文件。
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:19.1.0'
}
希望它有帮助!
的FirebaseUI-Android库0.6.0
版本包括采取火力地堡StorageReference
并加载使用滑翔图像的能力:
// Reference to an image file in Firebase Storage
StorageReference storageReference = ...;
// ImageView in your Activity
ImageView imageView = ...;
// Load the image using Glide
Glide.with(this /* context */)
.using(new FirebaseImageLoader())
.load(storageReference)
.into(imageView);
要包含它,只需添加compile 'com.firebaseui:firebase-ui-storage:0.6.0'
您build.gradle
。
如何从特定尺寸的Firebase获取图片? – ono
我们目前在FirebaseUI中不支持此功能,您需要自行上传已调整大小的图像。一个很好的方法是使用Firebase的云端函数。 –
•尝试添加应用级依赖
dependencies {
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:0.6.0'
}
•使用下一个代码从火力存储
ImageView imageView = findViewById(R.id.image_view);
Glide.with(context)
.using(new FirebaseImageLoader())
.load(pathReference)
.into(imageView);
获得图像在我们的[零到App通话(HTTPS: //www.youtube.com/watch?v=xAsvwy1-oxE)在Google I/O上使用了Android应用程序中的设置。看看[该应用程序的代码](https://gist.github.com/puf/f49a1b07e92952b44f2dc36d9af04e3c)开始。 –
谢谢。但我的意思是,在我的应用程序中,我想显示应用程序附带的照片,这些照片已存在于Firebase存储中,而不是用户上传的照片。你知道在这种情况下读取存储的最佳实践是什么? – FVbes