如何在给定的屏幕截图中设置图像而不是关闭文本?

how to set image instead of Close text in given screenshot?

I am unable set image instead of close text using canvas.Close text is created using below method.

private void drawCenterText(Canvas canvas, Paint paint) {
    paint.setColor(mToggleMenuTextColor);
    switch (mOrientation) {
    case VERTICAL_RIGHT:
        canvas.drawText(openMenuText,
                getWidth() - paint.measureText(openMenuText),
                getHeight() / 2, paint);

        break;
    case VERTICAL_LEFT:
        canvas.drawText(openMenuText, 2, getHeight() / 2, paint);

        break;
    case HORIZONTAL_TOP:
        canvas.drawText(openMenuText,
                (getWidth() / 2) - (paint.measureText(openMenuText) / 2),
                textSize, paint);

        break;
    case HORIZONTAL_BOTTOM:
        canvas.drawText(openMenuText,
                (getWidth() / 2) - (paint.measureText(openMenuText) / 2),
                getHeight() - (textSize), paint);

        break;
    }
}

我希望这对你有所帮助,我还没有尝试过,但它应该能让你开始。

 @Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int width = getWidth();
    int height = getHeight();

    int bitWidth = b.getWidth();
    int bitHeight = b.getHeight();

    if (width > 0 && height > 0)
        canvas.drawBitmap(b, (width / 2) - (bitWidth / 2), height - (bitHeight), mPaint);
    else
        canvas.drawBitmap(b, 0, 0, mPaint);
}

其中 b 是我的位图,任何图标都初始化为

 b = BitmapFactory.decodeResource(getResources(), R.drawable.icon);