Glide according to the original size of the picture display network

Today encounter a problem, there are pictures to the server over, App loaded with Glide framework, but the picture has finished loading on the Meizu phone stays full fill the entire area, which is obviously not the effect to be achieved, the code is as follows:

Glide.with(ctx)
     .load(img_url)
     .dontAnimate()
     .placeholder(R.drawable.ic_logo)
     .into(invitateImg);

We take a look at the original picture (I added a red border)


FIG facie effect, the picture directly to the filling stays full control following a broken line



We need GlideDrawableImageViewTarget move about the knife:

private Drawable placeholder;

placeholder = ContextCompat.getDrawable(mContext, R.drawable.ic_logo_shuiyin);

Glide.with(JssApplication.app)
      .load(img_url)
      .dontAnimate()
      .placeholder(placeholder)
      .into(new GlideDrawableImageViewTarget(invitateImg) {
          @Override
          public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
              super.onResourceReady(drawable, anim);
              placeholder = drawable;
          }
      });

Effect is perfect!






.

Published 59 original articles · won praise 88 · views 190 000 +

Guess you like

Origin blog.csdn.net/geofferysun/article/details/78084677