Android Jetpack | ||||||||||
| ||||||||||
| ||||||||||
| ||||||||||
| ||||||||||
|
Palette, Android Jetpack UI Components, Pull useful information out of color palettes
Below are the required sdk version and dependencies for using the Palette library
compileSdkVersion 28
minSdkVersion 24
targetSdkVersion 28
dependencies
{
...
implementation 'com.android.support:palette-v7:28.0.0'
}
A Palette object gives you access to the primary colors in an image, as well as the corresponding colors for overlaid text.
palette library contains six color profiles as listed below, each method associated with that particular profile returns the color in the palette, return palette might be null.
Profile | Method |
---|---|
Light Vibrant | getLightVibrantSwatch() |
Vibrant | getVibrantSwatch() |
Dark Vibrant | getDarkVibrantSwatch() |
Light Muted | getLightMutedSwatch() |
Muted | getMutedSwatch() |
Dark Muted | getDarkMutedSwatch() |
Method to Generate Palette instance
public Palette generatePalette(Bitmap bitmap)
{
Palette p = Palette.from(bitmap).generate();
return p;
}
Code to extracts prominent colors from images
Bitmap bitMap = BitmapFactory.decodeFile( picturePath);
Palette p = generatePalette( bitMap);
Palette.Swatch vibrantSwatch = p.getVibrantSwatch();
if( vibrantSwatch != null)
{
// extracts prominent colors
int backgroundColor = vibrantSwatch.getRgb();
int textColor = vibrantSwatch.getTitleTextColor();
}
The Sample Project is available for Download from GitHub.
Animation & transitions, Android Jetpack UI Components, Move widgets and transition between screens
posted on 2019-10-25 08:04:17 - Android Jetpack Tutorials
Emoji, Android Jetpack UI Components, Enable an up-to-date emoji font on older platforms
posted on 2019-10-25 08:03:43 - Android Jetpack Tutorials
Fragment, Android Jetpack UI Components, A basic unit of composable UI
posted on 2019-10-25 08:03:24 - Android Jetpack Tutorials