Skip to content

Instantly share code, notes, and snippets.

@yhirano
Last active November 4, 2017 11:33
Show Gist options
  • Select an option

  • Save yhirano/5cf11aaad1168057aadd54ca18565788 to your computer and use it in GitHub Desktop.

Select an option

Save yhirano/5cf11aaad1168057aadd54ca18565788 to your computer and use it in GitHub Desktop.
Show original image size on Glide4.
GlideApp.with(imageView.getContext())
.load(url)
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
if (resource instanceof BitmapDrawable) {
int width = ((BitmapDrawable) resource).getBitmap().getWidth();
int height = ((BitmapDrawable) resource).getBitmap().getHeight();
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.width = width;
layoutParams.height = height;
imageView.setLayoutParams(layoutParams);
}
imageView.setImageDrawable(resource);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment