Glide when rotating device does not crop properly centered on Android

1

Definition of ImageView

<ImageView
    android:id="@+id/cover_image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:contentDescription="@string/desc_empty"
    android:fitsSystemWindows="true"
    android:scaleType="centerCrop" />

Java code using glide for loading

Glide.with(this)
        .load(entry.getCover_photo())
        .placeholder(R.drawable.default_image)
        .error(R.drawable.error_image)
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .crossFade()
        .into(ivCover);

The problem I have is in the rotation of the device:

vertical(bien) -> horizontal(se muestra aumentado) -> vertical(bien) -> horizontal(bien)

that is, the second time it is rotated, everything is displayed correctly. and continuously until you leave the activity

    
asked by Webserveis 19.04.2017 в 19:47
source

1 answer

1

I found a solution in this Incidence by reforming the code to the new version of Glide 3.7 stays like this

String src = "url de la imagen";

Glide.with(this)
        .load(src)
        .asBitmap()
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(new BitmapImageViewTarget(imageView) {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                super.onResourceReady(resource, glideAnimation);
                Glide.with(imageView.getContext())
                        .load(src)
                        .centerCrop().into(imageView);

            }
        });
    
answered by 19.04.2017 / 19:47
source