Example usage for android.graphics Paint setColor

List of usage examples for android.graphics Paint setColor

Introduction

In this page you can find the example usage for android.graphics Paint setColor.

Prototype

public void setColor(@ColorInt int color) 

Source Link

Document

Set the paint's color.

Usage

From source file:in.sc9.discreteslider.DiscreteSlider.java

private void drawTextArray(Canvas canvas, int thumbWidth, int halfThumb, float yPos, int left, float intervel) {
    int lenTextArray = textArray.length;
    if (lenTextArray == 0)
        return;/*from w ww  .  j  a  va  2s . c o m*/

    float currentLeft = left;

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setTextAlign(Paint.Align.LEFT);
    paint.setColor(mtextColor);
    paint.setTextSize(mTextSize);
    //paint.setTypeface(); //TODO setTypeface in Discrete Seek Bar
    //elloWorldTextView2.setTextSize(activity.pixelsToSp(activity, textSize));
    //paint.m

    for (int i = 0; i < lenTextArray; i++) {
        /*if((int)getThumbValue(0)==i*(int)scaleStep)
        paint.setColor(Color.parseColor("#ffff0000"));
        else
        paint.setColor(Color.parseColor("#ff22445b"));*/

        float textLen = paint.measureText(textArray[i]);

        if (i == 0) {
            if (textStyle != NONE && (textStyle == ODD || textStyle == EXTREMES || textStyle == ALL))
                canvas.drawText(textArray[i], currentLeft, yPos, paint);
        } else if (i == lenTextArray - 1) {
            if (textStyle != NONE)
                if ((textStyle == ALL) || (i % 2 == 0 && textStyle == ODD) || (i % 2 != 0 && textStyle == EVEN)
                        || (textStyle == EXTREMES))
                    canvas.drawText(textArray[i], currentLeft - textLen, yPos, paint);
        } else {
            if (textStyle != 0 && textStyle != 3) {
                if ((textStyle == ALL) || (i % 2 == 0 && textStyle == ODD) || (i % 2 != 0 && textStyle == EVEN))
                    canvas.drawText(textArray[i], currentLeft - (textLen / 2), yPos, paint);
            }
        }
        currentLeft += intervel;
    }
}

From source file:com.cssweb.android.view.KlineMini.java

public void drawQuoteWin(Canvas canvas, JSONObject quoteData, int idx) throws JSONException {
    Paint mPaint = new Paint();
    mPaint.setTextAlign(Paint.Align.LEFT);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mPaint.setAntiAlias(true);/*www  . j a v a2 s  .c o  m*/

    mPaint.setColor(GlobalColor.colorKlinePopub);
    mPaint.setTextSize(sTextSize);
    canvas.drawText(":", 0, axisLabelHeight, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 3, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 5, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 7, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 9, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 11, mPaint);

    mPaint.setTextAlign(Paint.Align.RIGHT);
    String qt = quoteData.getJSONArray("K").getJSONArray(idx).getString(0);
    double jrkp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(1);
    double zg = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(2);
    double zd = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(3);
    double sp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4);
    double preclose;
    if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) {
        switch (idx) {
        case 0:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(7);
            break;
        default:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(7);
            break;
        }
        if (quoteData.getJSONArray("K").length() == 1) {
            preclose = quoteData.getJSONArray("K").getJSONArray(0).getDouble(7);
        }
    } else {
        switch (idx) {
        case 0:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4);
            break;
        default:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(4);
            break;
        }
        if (quoteData.getJSONArray("K").length() == 1) {
            preclose = quoteData.getDouble("zrsp");//quoteData.getJSONArray("K").getJSONArray(0).getDouble(4);
        }
    }
    //      if(quoteData.getJSONArray("K").length()==1 && quoteData.getJSONObject("todayData")!=null){
    //         preclose = quoteData.getJSONObject("todayData").getDouble("zrsp");
    //      }
    mPaint.setColor(getcolor(jrkp, preclose));
    canvas.drawText(Utils.dataFormation(jrkp, stockdigit), klineX, axisLabelHeight * 2, mPaint);
    mPaint.setColor(getcolor(zg, preclose));
    canvas.drawText(Utils.dataFormation(zg, stockdigit), klineX, axisLabelHeight * 4, mPaint);
    mPaint.setColor(getcolor(zd, preclose));
    canvas.drawText(Utils.dataFormation(zd, stockdigit), klineX, axisLabelHeight * 6, mPaint);
    mPaint.setColor(getcolor(sp, preclose));
    canvas.drawText(Utils.dataFormation(sp, stockdigit), klineX, axisLabelHeight * 8, mPaint);
    double zhangdie = sp - preclose;
    if (zhangdie > 0)
        mPaint.setColor(GlobalColor.colorpriceUp);
    else if (zhangdie < 0)
        mPaint.setColor(GlobalColor.colorPriceDown);
    else
        mPaint.setColor(GlobalColor.colorPriceEqual);
    canvas.drawText(Utils.dataFormation(zhangdie, 1), klineX, axisLabelHeight * 10, mPaint);
    if (quoteData.getString("period").equals("min5") || quoteData.getString("period").equals("min15")
            || quoteData.getString("period").equals("min30") || quoteData.getString("period").equals("min60")) {
        qt = qt.substring(4, 6) + '/' + qt.substring(6, 8) + ' ' + qt.substring(8);
    } else {
        qt = qt.substring(2, 4) + qt.substring(4, 6) + qt.substring(6, 8);
    }
    mPaint.setColor(GlobalColor.colorLabelName);
    canvas.drawText(qt, klineX, axisLabelHeight * 12, mPaint);
}

From source file:com.htc.dotdesign.DrawingView.java

private Bitmap handlePicture() {
    Paint paint = new Paint();
    Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    int[][] mCloneArray = new int[mRowSize][mColSize];
    float left = 0;
    float top = 0;
    float right = sDotPixelWidth;
    float bottom = sDotPixelHeight;
    for (int row = 0; row < mRowSize; ++row) {
        for (int col = 0; col < mColSize; ++col) {
            if (mImgDotMatrix[row][col] == Color.TRANSPARENT) {
                mCloneArray[row][col] = Color.BLACK;
            } else {
                mCloneArray[row][col] = mImgDotMatrix[row][col];
            }/*from  w  w  w  . j av a2  s  . c o  m*/
            paint.setColor(mCloneArray[row][col]);
            canvas.drawRect(left, top, right, bottom, paint);
            left += sDotPixelWidth;
            right += sDotPixelWidth;
        }
        left = 0;
        right = sDotPixelWidth;
        top += sDotPixelHeight;
        bottom += sDotPixelHeight;
    }
    return bitmap;
}

From source file:com.hippo.widget.Slider.java

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
    mContext = context;/*  ww w . j av a  2  s .  c  om*/
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextAlign(Paint.Align.CENTER);

    Resources resources = context.getResources();
    mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width);
    mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height);

    mBubble = new BubbleView(context, textPaint);
    mBubble.setScaleX(0.0f);
    mBubble.setScaleY(0.0f);
    AbsoluteLayout absoluteLayout = new AbsoluteLayout(context);
    absoluteLayout.addView(mBubble);
    absoluteLayout.setBackgroundDrawable(null);
    mPopup = new PopupWindow(absoluteLayout);
    mPopup.setOutsideTouchable(false);
    mPopup.setTouchable(false);
    mPopup.setFocusable(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider);
    textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE));
    textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12));

    updateTextSize();

    setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0));
    setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0));
    mThickness = a.getDimension(R.styleable.Slider_thickness, 2);
    mRadius = a.getDimension(R.styleable.Slider_radius, 6);
    setColor(a.getColor(R.styleable.Slider_color, Color.BLACK));

    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000);

    a.recycle();

    mProgressAnimation = new ValueAnimator();
    mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawPercent = value;
            mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value));
            updateBubblePosition();
            mBubble.setProgress(mDrawProgress);
            invalidate();
        }
    });

    mBubbleScaleAnimation = new ValueAnimator();
    mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawBubbleScale = value;
            mBubble.setScaleX(value);
            mBubble.setScaleY(value);
            invalidate();
        }
    });
}

From source file:org.jraf.android.piclabel.app.form.FormActivity.java

private void drawText(Canvas canvas) {
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);//from w  w w  .  j  a v a  2 s. c  o  m
    paint.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/" + getSelectedFontName()));

    int textSize = canvas.getHeight() / 35;
    paint.setTextSize(textSize);
    int margin = textSize / 5;

    // Measure date/time
    String dateTime = mEdtDateTime.getText().toString();
    Rect boundsDateTime = new Rect();
    paint.getTextBounds(dateTime, 0, dateTime.length(), boundsDateTime);

    // Measure location
    String location = mEdtLocation.getText().toString();
    Rect boundsLocation = new Rect();
    paint.getTextBounds(location, 0, location.length(), boundsLocation);

    int totalWidth = boundsDateTime.width() + textSize * 2 + boundsLocation.width();
    if (totalWidth > canvas.getWidth()) {
        // Draw on 2 lines

        // Draw a rectangle
        paint.setColor(Color.argb(180, 0, 0, 0));
        canvas.drawRect(0, 0, canvas.getWidth(), -boundsDateTime.top + boundsDateTime.bottom
                + -boundsLocation.top + boundsLocation.bottom + margin * 3, paint);

        // Draw date/time
        paint.setColor(Color.WHITE);
        canvas.drawText(dateTime, margin, margin + -boundsDateTime.top, paint);

        // Draw location
        canvas.drawText(location, canvas.getWidth() - boundsLocation.right - boundsLocation.left - margin,
                margin + -boundsDateTime.top + boundsDateTime.bottom + margin + -boundsLocation.top, paint);

    } else {
        // Draw on 1 line

        // Draw a rectangle
        paint.setColor(Color.argb(180, 0, 0, 0));
        canvas.drawRect(0, 0, canvas.getWidth(),
                margin + Math.max(boundsDateTime.height(), boundsLocation.height()) + margin, paint);

        // Draw date/time
        paint.setColor(Color.WHITE);
        canvas.drawText(dateTime, margin, margin + -boundsDateTime.top, paint);

        // Draw location
        canvas.drawText(location, canvas.getWidth() - boundsLocation.right - boundsLocation.left - margin,
                margin + -boundsLocation.top, paint);
    }
}

From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java

private void drawSelector(Canvas canvas, int index, Path selectorPath, float alphaMod) {
    final int alpha = (int) (mAlpha[index % 2].getValue() * alphaMod + 0.5f);
    final int color = applyAlpha(mSelectorColor, alpha);

    // Calculate the current radius at which to place the selection circle.
    final int selRadius = mSelectorRadius;
    final int selLength = mCircleRadius - mTextInset[index];
    final double selAngleRad = Math.toRadians(mSelectionDegrees[index % 2]);
    final float selCenterX = mXCenter + selLength * (float) Math.sin(selAngleRad);
    final float selCenterY = mYCenter - selLength * (float) Math.cos(selAngleRad);

    // Draw the selection circle.
    final Paint paint = mPaintSelector[index % 2][SELECTOR_CIRCLE];
    paint.setColor(color);
    canvas.drawCircle(selCenterX, selCenterY, selRadius, paint);

    // If needed, set up the clip path for later.
    if (selectorPath != null) {
        selectorPath.reset();//from   w  w w .  ja v a 2  s .co m
        selectorPath.addCircle(selCenterX, selCenterY, selRadius, Path.Direction.CCW);
    }

    // Draw the dot if we're between two items.
    final boolean shouldDrawDot = mSelectionDegrees[index % 2] % 30 != 0;
    if (shouldDrawDot) {
        final Paint dotPaint = mPaintSelector[index % 2][SELECTOR_DOT];
        dotPaint.setColor(mSelectorDotColor);
        canvas.drawCircle(selCenterX, selCenterY, mSelectorDotRadius, dotPaint);
    }

    // Shorten the line to only go from the edge of the center dot to the
    // edge of the selection circle.
    final double sin = Math.sin(selAngleRad);
    final double cos = Math.cos(selAngleRad);
    final int lineLength = selLength - selRadius;
    final int centerX = mXCenter + (int) (mCenterDotRadius * sin);
    final int centerY = mYCenter - (int) (mCenterDotRadius * cos);
    final float linePointX = centerX + (int) (lineLength * sin);
    final float linePointY = centerY - (int) (lineLength * cos);

    // Draw the line.
    final Paint linePaint = mPaintSelector[index % 2][SELECTOR_LINE];
    linePaint.setColor(color);
    linePaint.setStrokeWidth(mSelectorStroke);
    canvas.drawLine(mXCenter, mYCenter, linePointX, linePointY, linePaint);
}

From source file:org.telegram.ui.Components.NumberPicker.java

private void init() {
    mSolidColor = 0;/*from w  w  w  . j av a  2 s . c  o  m*/
    mSelectionDivider = new ColorDrawable(ContextCompat.getColor(getContext(), R.color.colorAccent) & 0x00ffffff
            | (0x9f << 24)) /*getResources().getDrawable(R.drawable.numberpicker_selection_divider)*/;

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180,
            getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64,
            getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mVirtualButtonPressedDrawable = getResources().getDrawable(R.drawable.item_background_holo_light);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    addView(mInputText);
    mInputText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity()
            / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}

From source file:info.bartowski.easteregg.MLand.java

@Override
public void onDraw(Canvas c) {
    super.onDraw(c);

    if (SHOW_TOUCHES) {
        for (Player p : mPlayers) {
            if (p.mTouchX > 0) {
                mTouchPaint.setColor(0x80FFFFFF & p.color);
                mPlayerTracePaint.setColor(0x80FFFFFF & p.color);
                float x1 = p.mTouchX;
                float y1 = p.mTouchY;
                c.drawCircle(x1, y1, 100, mTouchPaint);
                float x2 = p.getX() + p.getPivotX();
                float y2 = p.getY() + p.getPivotY();
                float angle = PI_2 - (float) Math.atan2(x2 - x1, y2 - y1);
                x1 += 100 * Math.cos(angle);
                y1 += 100 * Math.sin(angle);
                c.drawLine(x1, y1, x2, y2, mPlayerTracePaint);
            }/*from   w w w  .  ja v a2 s .  com*/
        }
    }

    if (!DEBUG_DRAW)
        return;

    final Paint pt = new Paint();
    pt.setColor(0xFFFFFFFF);
    for (Player p : mPlayers) {
        final int L = p.corners.length;
        final int N = L / 2;
        for (int i = 0; i < N; i++) {
            final int x = (int) p.corners[i * 2];
            final int y = (int) p.corners[i * 2 + 1];
            c.drawCircle(x, y, 4, pt);
            c.drawLine(x, y, p.corners[(i * 2 + 2) % L], p.corners[(i * 2 + 3) % L], pt);
        }
    }

    pt.setStyle(Paint.Style.STROKE);
    pt.setStrokeWidth(getResources().getDisplayMetrics().density);

    final int M = getChildCount();
    pt.setColor(0x8000FF00);
    for (int i = 0; i < M; i++) {
        final View v = getChildAt(i);
        if (v instanceof Player)
            continue;
        if (!(v instanceof GameView))
            continue;
        if (v instanceof Pop) {
            final Pop pop = (Pop) v;
            c.drawCircle(pop.cx, pop.cy, pop.r, pt);
        } else {
            final Rect r = new Rect();
            v.getHitRect(r);
            c.drawRect(r, pt);
        }
    }

    pt.setColor(Color.BLACK);
    final StringBuilder sb = new StringBuilder("obstacles: ");
    for (Obstacle ob : mObstaclesInPlay) {
        sb.append(ob.hitRect.toShortString());
        sb.append(" ");
    }
    pt.setTextSize(20f);
    c.drawText(sb.toString(), 20, 100, pt);
}

From source file:com.lt.adamlee.aagame.GameView.java

public void about(Canvas c) {
    int textsize = (int) F.hf(20.0f);
    Paint p3 = new Paint();
    p3.setTypeface(tf);/*from w  ww .  ja va2  s .c  o  m*/
    p3.setColor(ViewCompat.MEASURED_STATE_MASK);
    p3.setFlags(1);
    p3.setTextSize((float) textsize);
    Paint pagepaint = new Paint();
    pagepaint.setColor(getResources().getColor(R.color.abc_secondary_text_material_light));
    c.drawRect(0.0f, 0.0f, (float) screenW, (float) screenH, pagepaint);
    p3.setTextSize(F.hf(30.0f));
    c.drawText(ctx.getString(R.string.about),
            ((float) (screenW / 2)) - (p3.measureText(ctx.getString(R.string.about)) / 2.0f),
            (float) (screenH / 4), p3);
    p3.setTextSize((float) textsize);
    c.drawText(ctx.getString(R.string.app_name),
            ((float) (screenW / 2)) - (p3.measureText(ctx.getString(R.string.app_name)) / 2.0f),
            (float) (((textsize * 2) + 1) + ((screenH - (textsize * 7)) / 2)), p3);
    c.drawText("License Version 1.7", ((float) (screenW / 2)) - (p3.measureText("License Version 1.7") / 2.0f),
            (float) (((textsize * 3) + 1) + ((screenH - (textsize * 7)) / 2)), p3);
    p3.setTextSize(F.hf(17.0f));
    c.drawText("Powered by Map Game Studio",
            ((float) (screenW / 2)) - (p3.measureText("Powered by Map Game Studio") / 2.0f),
            (float) (((textsize * 4) + 1) + ((screenH - (textsize * 7)) / 2)), p3);
    p3.setTextSize(F.hf(17.0f));
    c.drawText("Email:mapgamestudio@gmail.com",
            ((float) (screenW / 2)) - (p3.measureText("Email:mapgamestudio@gmail.com") / 2.0f),
            (float) (((textsize * 5) + 1) + ((screenH - (textsize * 7)) / 2)), p3);
}

From source file:com.android.launcher3.Utilities.java

public static Bitmap getNotificationBadgeIcon(Context context, Bitmap appIcon, int number) {
    Paint paint;
    Paint circlePaint;/*from   w  w w . j  a va2  s  . c o  m*/
    String text = "" + String.valueOf(number);
    Bitmap canvasBitmap = Bitmap.createBitmap(appIcon.getWidth(), appIcon.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(canvasBitmap);
    paint = new Paint();
    circlePaint = new Paint();

    paint.setColor(Color.WHITE);
    paint.setTextSize(45);
    paint.setAntiAlias(true);
    paint.setTextAlign(Paint.Align.CENTER);

    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);

    circlePaint.setColor(ContextCompat.getColor(context, R.color.colorPrimary));
    circlePaint.setAntiAlias(true);

    canvas.drawCircle(appIcon.getWidth() / 4, appIcon.getHeight() / 4, 45, circlePaint);
    canvas.drawText(text, appIcon.getWidth() / 4, appIcon.getHeight() / 3, paint);

    return overlay(appIcon, canvasBitmap);
}