Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

 

Show the video description

In this video we will learn, how to use the Palette class to extract colors from an image and style our UI with them. We will generate a Palette asynchronously, which will by default extract 16 prominent colors from a bitmap and build 16 swatches with them. These swatches also provide an appropriate title and body text color that fit beautifuly to the main swatch color. From the 16 swatches, the system will automatically calculate the 6 color profiles that are most commonly used to style user interfaces: vibrant, light vibrant, dark vibrant, muted, light muted and dark muted. If it doesn’t find a color that fits to a profile, it will return null for the corresponding swatch. We can increase the likelyhood of a fit by extracting more colors with the maximumColorCount method.

Important Linksactivity_main.xmlMainActivity.java