Last active
November 4, 2017 11:33
-
-
Save yhirano/5cf11aaad1168057aadd54ca18565788 to your computer and use it in GitHub Desktop.
Show original image size on Glide4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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