简体   繁体   English

Firebase图片无法正确放大

[英]Firebase Images are not properly scaling up

I am working on an application which uses Google Firebase and RecyclerView. 我正在使用Google Firebase和RecyclerView的应用程序上工作。 While retrieving the images from Firebease, images are not properly scaling up. 从Firebease检索图像时,图像无法正确放大。 When scrolling the recyclerview, sometimes images are showing as smaller ones and sometimes bigger. 滚动recyclerview时,有时图像显示为较小的图像,有时显示为较大的图像。 They are not scalling properly. 它们缩放不正确。 I am using Glide to load the images. 我正在使用Glide加载图像。 Please help me . 请帮我 。

Also, is it a good idea to use Recuyclerview to use in complex application since OnbindViewHolder being called multiple times causing performance issues. 另外,在复杂的应用程序中使用Recuyclerview是个好主意,因为OnbindViewHolder被多次调用会导致性能问题。 Is there any alternative for that. 有没有其他选择。

Please use this code: 请使用以下代码:

Glide.with(profilePhotoImageView.getContext())
     .load(profilePhotoUrl).centerCrop()
     .transform(new CircleTransform(profilePhotoImageView.getContext()))
     .override(40,40)
     .into(profilePhotoImageView);

This means that you are setting a fixed width and height. 这意味着您要设置固定的宽度和高度。 In which profilePhotoUrl is the url of your image and profilePhotoImageView is the ImageView in which you want to display the image. 其中profilePhotoUrl是图像的URL, profilePhotoImageView是要在其中显示图像的ImageView。

And don't forget to add the latest version of Glide in your build.gradle file. 并且不要忘记在build.gradle文件中添加最新版本的Glide

'com.github.bumptech.glide:glide:4.0.0-RC1'

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM