Reputation: 11
My question is how an application like YouTube music and Spotify change the colour of the background with respect to the poster of any song.
I am giving an example how what it looks like and if anyone can help me to achieve this then please help me.
If anyone can give me a java code example for this then it will help me a lot. Thank you.
Upvotes: 1
Views: 316
Reputation: 357
use this library from google, click Here to read more about it
implementation 'androidx.palette:palette:1.0.0'
Example of usage
Palette.from(bitmap).generate(palette -> {
//There is alot of methods you can use whatever wherever you want
int rgb = palette.getMutedSwatch().getRgb();
int vibrant = palette.getVibrantSwatch().getRgb();
int vibrantDark = palette.getDarkVibrantSwatch().getRgb();
int vibrantLight = palette.getLightVibrantSwatch().getRgb();
int muted = palette.getMutedSwatch().getRgb();
int mutedDark = palette.getDarkMutedSwatch().getRgb();
int mutedLight = palette.getLightMutedSwatch().getRgb()
});
and this method is useful if you want hex color
private String rgbToHex(int rgb) {
return String.format("%06x", 0xFFFFFF & rgb);
}
Upvotes: 1