Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve following on placeholder image in ImageView Android like Pinterest?

I have used Picasso in my Android Application which has many images. Its working and looking good. I am trying to make UI more of simple and user friendly. I have placeholder for my imageviews before actual image loads. But its white color. I want to placeholder image depending on main color of image like pinterest.

Pinterest placeholder images before main image loads. Following screenshot:

enter image description here

And after image loads it shows proper image based on main background color shown for placeholder:

enter image description here

Is it possible to achieve in Picasso library provided by Square or whats the way to achieve.

Please help.

like image 280
virendrao Avatar asked Nov 10 '22 23:11

virendrao


1 Answers

Bit late but for other readers that want to accomplish a similar thing, I'll just leave this here. I don't know how Pinterest did/does it, probably developed their own implementation. But Google updated the v7 support library with 'Palette' which is a new API which allows you to extract prominent colours from images when provided with an Image Bitmap.

Edit: Something I just realised that this probably doesn't help for placeholders since you need an image to actually get colours from! So my best guess is that Pinterest does the colour extraction from the server and includes the colour in the (presumably) JSON response that is sent to the client.

I haven't used it much myself but it works quite well from what I've seen/read. You can read up more about it at these two places:

Developer Docs
Tutorial/Explanation (Willow Tree Apps)

like image 195
David Liaw Avatar answered Nov 14 '22 23:11

David Liaw