private static IconCompat generateThemedIcon(Context context, int iconId, int foregroundColor, int backgroundColor) {
// Get and tint foreground and background drawables
Drawable vectorDrawable = Util.getTintedVectorDrawable(context, iconId, foregroundColor);
Drawable backgroundDrawable = Util.getTintedVectorDrawable(context, R.drawable.ic_app_shortcut_background, backgroundColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(backgroundDrawable, vectorDrawable);
return IconCompat.createWithAdaptiveBitmap(drawableToBitmap(adaptiveIconDrawable));
} else {
// Squash the two drawables together
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{backgroundDrawable, vectorDrawable});
// Return as an Icon
return IconCompat.createWithBitmap(drawableToBitmap(layerDrawable));
}
}
AppShortcutIconGenerator.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:Phonograph
作者:
评论列表
文章目录