(Android) Resizing images with a transparent background?

Viewed 150

I'm getting images through an API, except the problem is that all the images are in a fixed size, which leaves large pictures okay since it takes up the whole space, but there are some pictures with small objects, as shown here

image_large

I was wondering if there is a way to detect if an image with a transparent background can be resized to only what's shown such as here

image_small

The libraries I'm using for this are glide to get the images from a URL and GifImageView to hold the image. Any help would be appreciative.

1 Answers

I think that scalingtype attribute will be helpful. And with glide, there is a method called apply() that you can use it to determine the option that you can use to modify you imageView

RequestOptions cropOptions = new RequestOptions().centerCrop(context); ... Glide.with(fragment) .load(url) .apply(cropOptions) .into(imageView); You can benefit from the documentations of glide library

https://bumptech.github.io/glide/doc/options.html

Related