Firebase图片未正确扩展

时间:2017-07-10 00:24:26

标签: android firebase firebase-realtime-database

我正在开发一个使用Google Firebase和RecyclerView的应用程序。从Firebease检索图像时,图像未正确放大。滚动Recyclerview时,有时图像显示为较小的,有时更大。他们没有正确的剥落。我正在使用Glide加载图像。请帮我 。

此外,使用Recuyclerview在复杂的应用程序中使用是个好主意,因为多次调用OnbindViewHolder会导致性能问题。有没有替代方案。

1 个答案:

答案 0 :(得分:0)

请使用此代码:

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

这意味着您要设置固定的宽度和高度。其中profilePhotoUrl是图片的网址,profilePhotoImageView是您要在其中显示图片的ImageView。

不要忘记在build.gradle文件中添加最新版本的Glide

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

希望它有所帮助。