I am trying to use the palette function of androids material design but I am having some trouble in applying it.
I have successfully generated the palette and now I am trying to pass the palette into a function that applies the it.
The problem that I am having is that when I pass in the palette to the applyPalette
function none of the methods like palette.getDarkMutedColor().getRgb() , palette.getVibrantColor().getRgb()
are being populated with the values from the palette.
The tutorial that I was following didnt mention anything else other then passing in the palette to the function, and in doing so the methods would be populated
This is the generator Function and the applying function, can any one see why this isnt working?
Code
private void colorize(Bitmap photo) {
Palette palette = new Palette.Builder(photo).generate();
applyPalette(palette);
}
private void applyPalette(Palette palette) {
getWindow().setBackgroundDrawable(new ColorDrawable(palette.getDarkMutedColor().getRgb()));
TextView titleView = (TextView) findViewById(R.id.title);
titleView.setTextColor(palette.getVibrantColor().getRgb());
TextView descriptionView = (TextView) findViewById(R.id.description);
descriptionView.setTextColor(palette.getLightVibrantColor().getRgb());
colorRipple(R.id.info, palette.getDarkMutedColor().getRgb(),
palette.getDarkVibrantColor().getRgb());
colorRipple(R.id.star, palette.getMutedColor().getRgb(),
palette.getVibrantColor().getRgb());
View infoView = findViewById(R.id.information_container);
infoView.setBackgroundColor(palette.getLightMutedColor().getRgb());
AnimatedPathView star = (AnimatedPathView) findViewById(R.id.star_container);
star.setFillColor(palette.getVibrantColor().getRgb());
star.setStrokeColor(palette.getLightVibrantColor().getRgb());
}
use picassopalette third party library and import it into your project then use following code:
try {
ContextWrapper cw = new ContextWrapper(OtherUserProfileScreenActivity.this);
Picasso.with(this).load(image + ".jpg").placeholder(R.drawable.ic_loading).error(R.drawable.ic_error).into(imageView, PicassoPalette.with(Image + ".jpg", imageView).use(PicassoPalette.Profile.MUTED_DARK).intoCallBack(new BitmapPalette.CallBack() {
@Override
public void onPaletteLoaded(Palette palette) {
int mutedColor = palette.getMutedColor(R.attr.colorPrimary);
mCollapsingToolbarLayout.setContentScrimColor(mutedColor);
}
}));
} catch (OutOfMemoryError e) {
e.printStackTrace();
System.gc();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With