Glide.with(context).asBitmap().load(imgUrl).into(new CustomTarget<Bitmap>() {
@SuppressLint("ClickableViewAccessibility")
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
Palette.from(resource).generate(new Palette.PaletteAsyncListener() {
public void onGenerated(Palette p) {
// Use generated instance
// cardView.setBackgroundColor(p.getLightVibrantColor(0XFFF2F2F2));
int color = p.getVibrantColor(0XFF06B5B7);
image1.setImageTintList(ColorStateList.valueOf(color));
image2.setImageBitmap(resource);
number.setTextColor(color);
unit.setTextColor(color);
}
});
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
Android 根据图片颜色动态设置文字颜色、主题色
最新推荐文章于 2025-03-05 13:58:13 发布