Closed demandedcross closed 9 years ago
Do you want to change the color of button during runtime? If not, try to customize it via styles, like here.
It's hard to understand what you are doing without code examples.
Yeah it's during runtime, using the Palette api to get the colour from a bitmap loaded from a url.
Glide.with(App.me).load(coverUrl).asBitmap().thumbnail(0.2f).animate(R.anim.abc_fade_in).into(new BitmapImageViewTarget(movieDetailCoverImage) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
super.onResourceReady(bitmap, anim);
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
public void onGenerated(Palette palette) {
// Do something with colors...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(palette.getDarkVibrantColor(Color.GRAY));
}
fab.setColor(palette.getVibrantColor(Color.GRAY));
fab.initBackground();
}
});
}
});
Try to add single line before fab.setColor(...)
:
fab.setColorStateList(null);
If this line will help, than I will fix the bug.
That fixes it :)
Okay, you may use this workaround, and I will fix it soon.
Not sure if this is a bug or something I'm doing wrong. I'm setting the color usin palette after glide has finished loading an image resource from a url into the view. The color is set correctly but then changes to a default gray color after it is clicked or just before the activity disappears and stays that color.