在绘制位图上绘制文本

Draw Text over Draw Bitmap

我有一个位图和一个文本。我只想在我的位图上放置一个文本,但问题是文本绘制在位图后面。谁能帮帮我?

     canvas.drawText("10", (mazeFinishX1 * totalCellWidth)
            + (cellWidth / 10), (mazeFinishY1 * totalCellHeight)
            + (cellHeight * 0.75f), ball);
     canvas.drawBitmap(lvl1_portal1, (mazeFinishX1 * totalCellWidth)
            + (cellWidth / 20), (mazeFinishY1 * totalCellHeight)
            + (cellWidth / 20), ball);

我已经测试过了。文本出现在位图后面。

先画位图,再画文字。

 canvas.drawBitmap(lvl1_portal1, (mazeFinishX1 * totalCellWidth)
        + (cellWidth / 20), (mazeFinishY1 * totalCellHeight)
        + (cellWidth / 20), ball);
 canvas.drawText("10", (mazeFinishX1 * totalCellWidth)
        + (cellWidth / 10), (mazeFinishY1 * totalCellHeight)
        + (cellHeight * 0.75f), ball);

订单很重要。

使用此代码。你画的顺序错了。

canvas.drawBitmap(lvl1_portal1, (mazeFinishX1 * totalCellWidth)
            + (cellWidth / 20), (mazeFinishY1 * totalCellHeight)
            + (cellWidth / 20), ball);
     canvas.drawText("10", (mazeFinishX1 * totalCellWidth)
            + (cellWidth / 10), (mazeFinishY1 * totalCellHeight)
            + (cellHeight * 0.75f), ball);