【发布时间】:2015-09-22 19:47:24
【问题描述】:
我有一个整数形式的颜色,我希望该颜色是位图形式。
有什么办法吗?
我试过了
Drawable d = new ColorDrawable(Color.parseColor("#ffffff"));
Bitmap b = ((BitmapDrawable)d).getbitmap();
但是上面的代码给出了错误 Cannot cast ColorDrawable to BitmapDrawable
还有其他方法吗?
实际代码是
Palette.generateAsync(BitmapFactory.decodeFile(songArt),
new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(final Palette palette) {
if (Build.VERSION.SDK_INT >= 16) {
Drawable colorDrawable = new ColorDrawable(palette.getDarkVibrantColor(
getResources().getColor(R.color.noti_background)));
notificationCompat.bigContentView.setImageViewResource(R.id.noti_color_bg,
((BitmapDrawable) colorDrawable).getBitmap());
notificationManager.notify(NOTIFICATION_ID, notificationCompat);
}
}
}
);
【问题讨论】:
标签: android bitmap notifications background-color