AppShortcutIconGenerator.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:Phonograph 作者:
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));
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号