android - Glide 正在加载半张图像

标签 android android-imageview android-drawable android-glide

当我尝试加载图像时,我得到以下结果:

Result

这是我的简单代码:

Glide.with(this).load(R.drawable.girl_with_coffee_and_phone)
                .placeholder(R.color.colorPrimary)
                .into(mBackgroundImage);

这是我的 Activity 布局:

<?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

最佳答案

尝试

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

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

在 Activity 中您将拥有:

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

关于android - Glide 正在加载半张图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39524604/

相关文章:

android - 为什么不推荐使用 InsertHelper?

android - 通过使用计时器(或处理程序)更改 ImageView 中的图像来创建动画

android - 如何获得一个不同 Drawable 的镜像版本的 Drawable?

android - 细蓝色进度条

java - Android Studio 的帮助系统?

java - 快速重新着色位图

android - PhotoView - 保持缩放和 xy 坐标

android - ImageView 中的动画位图(模拟报亭应用程序 - Ken Burns Effect)

Android - 向 ImageView 添加自定义边框

android - VectorDrawable 图像变得像素化