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);
}
BitmapUtil.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:shortstories
作者:
评论列表
文章目录