如何在 android 中使用 dynamicToolbarColor()
How to use dynamicToolbarColor() in android
以下代码仅从资源中获取一张图像,如何将其更改为动态图像,我将图像作为位图获取。
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.pfpic);
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
collapsingToolbarLayout.setContentScrimColor(palette.getMutedColor(R.attr.colorPrimary));
collapsingToolbarLayout.setStatusBarScrimColor(palette.getMutedColor(R.attr.colorPrimaryDark));
}
});
}
您只转换一张图像,您提到您正在获取位图形式的图像,对吗?!,为什么不使用该位图参考?!。
bmp = BitmapFactory.decodeByteArray(b, 0, b.length);
imageView.setImageBitmap(bmp);
您可以像这样在下面的代码中使用 'bmp'
Palette.from(bmp).generate(new Palette.PaletteAsyncListener() {
以下代码仅从资源中获取一张图像,如何将其更改为动态图像,我将图像作为位图获取。
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.pfpic);
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
collapsingToolbarLayout.setContentScrimColor(palette.getMutedColor(R.attr.colorPrimary));
collapsingToolbarLayout.setStatusBarScrimColor(palette.getMutedColor(R.attr.colorPrimaryDark));
}
});
}
您只转换一张图像,您提到您正在获取位图形式的图像,对吗?!,为什么不使用该位图参考?!。
bmp = BitmapFactory.decodeByteArray(b, 0, b.length);
imageView.setImageBitmap(bmp);
您可以像这样在下面的代码中使用 'bmp'
Palette.from(bmp).generate(new Palette.PaletteAsyncListener() {