Glide正在加载一半的图片。

6
当我尝试使用img src加载图像时,结果如下所示:

Result

这是我的简单代码:
Glide.with(this).load(R.drawable.girl_with_coffee_and_phone)
                .placeholder(R.color.colorPrimary)
                .into(mBackgroundImage);

这是我的活动布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <ImageView
        android:id="@+id/image_background"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"/>

</RelativeLayout>

我做错了什么吗?

日志:

D/OpenGLRenderer: endAllActiveAnimators on 0x7842bfdc00 (InsetDrawable) with handle 0x783169e820

检查一下你的日志,可能会打印出一些错误。 - Anjali
https://github.com/bumptech/glide/issues/700会对你有所帮助。 - Anjali
如 https://github.com/bumptech/glide 所述,大型图片(地图、漫画):Glide 可以通过降采样来加载大型图片,但不支持对 ImageView 进行缩放和平移,因为这需要特殊的资源优化(例如平铺)才能在没有 OutOfMemoryErrors 的情况下正常工作。 - Rahul Khurana
@user2299040 的重写没有修复。Askhay Bhat 也设置了 setLayerType。 - user5980999
遇到了同样的问题。我认为问题在于 Glide 内部。请查看 https://github.com/bumptech/glide/issues/391。 - Sayem
显示剩余5条评论
2个回答

0

尝试

  Glide.with(this).load(R.drawable.girl_with_coffee_and_phone)
                .centerCrop()
                .into(mBackgroundImage);

从XML文件中删除android:scaleType参数。

在活动中,您将拥有:

ImageView mBackgroundImage= (ImageView)findViewById(R.id.image_background);

不幸的是没有帮助。 - user5980999
是图片被切成两半还是包含它的图像视图? - Yordan
图片被切成了两半。 - user5980999
你尝试过不使用Glide吗?mBackgroundImage.setDrawable(getResources().getDrawable(R.drawable.girl_with_coffee_and_phone)) - Yordan

-1

我检查了源代码并找到了一个解决方法,只需查看我的 github 项目即可。


这并没有解释你是如何解决问题的。"查看此 Github 项目中的所有代码" 并不实用。 - Randy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接