Abhishek AN
Abhishek AN

Reputation: 808

Draw height of ImageView before loading from URL

I'm receiving an image from an API/Firebase storage and loading the URL into an image view using coil/glide/picasso. The height of the imageview is set to wrap content so once it is loaded it expands, how can I draw this height before loading like other apps do ( Ex: Reddit, FB, Instagram)

Do I upload the image bitmap height width values when storing the image and this could help me?

Attached video: https://streamable.com/nf4rk0

Upvotes: 0

Views: 244

Answers (2)

Ahmed senosy
Ahmed senosy

Reputation: 62

from what i get you need to set something like this

place holder image

this special effect can be done via multiple libraries Like this

but if you need to do just the height with a grey background, you can use any placeholder image and set it as a placeholder with your desired height it can be done also by picasso

Upvotes: 0

beastlyCoder
beastlyCoder

Reputation: 2401

With picasso, I would try something like this:

Picasso  
    .with(context)
    .load(/*The Image*/)
    .resize(600, 200) // resizes the image to these dimensions (in pixel). does not respect aspect ratio
    .into(imageViewResize);

This link gives a few more examples which may help you: https://futurestud.io/tutorials/picasso-image-resizing-scaling-and-fit

Upvotes: 0

Related Questions