/**
* Constructs the generator and initializes the common members ignoring display density.
*
* @param iconWidthPx The width of the generated icon in pixels.
* @param iconHeightPx The height of the generated icon in pixels.
* @param cornerRadiusPx The radius of the corners in the icon in pixels.
* @param backgroundColor Color at which the rounded rectangle should be drawn.
* @param textSizePx Size at which the text should be drawn in pixels.
*/
public RoundedIconGenerator(int iconWidthPx, int iconHeightPx, int cornerRadiusPx,
int backgroundColor, float textSizePx) {
mIconWidthPx = iconWidthPx;
mIconHeightPx = iconHeightPx;
mCornerRadiusPx = cornerRadiusPx;
mBackgroundRect = new RectF(0, 0, mIconWidthPx, mIconHeightPx);
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBackgroundPaint.setColor(backgroundColor);
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setColor(Color.WHITE);
mTextPaint.setFakeBoldText(true);
mTextPaint.setTextSize(textSizePx);
FontMetrics textFontMetrics = mTextPaint.getFontMetrics();
mTextHeight = (float) Math.ceil(textFontMetrics.bottom - textFontMetrics.top);
mTextYOffset = -textFontMetrics.top;
}
RoundedIconGenerator.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:Vafrinn
作者:
评论列表
文章目录