BitmapUtil.java 文件源码

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

项目:shortstories 作者:
private static Bitmap getCircleIcon(
        Context context, @ColorInt int backgroundColor, int backgroundInset,
        @DrawableRes int iconResId, @ColorInt int iconColor, int iconInset) {
    Drawable[] layers = new Drawable[2];
    ShapeDrawable background = new ShapeDrawable(new OvalShape());
    background.getPaint().setColor(backgroundColor);
    Drawable icon = ContextCompat.getDrawable(context, iconResId);
    Drawable tintedIcon = DrawableCompat.wrap(icon.mutate());
    DrawableCompat.setTint(tintedIcon, iconColor);
    layers[0] = background;
    layers[1] = tintedIcon;
    LayerDrawable layerDrawable = new LayerDrawable(layers);
    layerDrawable.setLayerInset(1, iconInset, iconInset, iconInset, iconInset);
    layerDrawable.setLayerInset(0, backgroundInset, backgroundInset, backgroundInset, backgroundInset);
    return drawableToBitmap(layerDrawable);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号