Android - 在 canvas 上的不同位置绘制图像和文本

Android - draw image and texts on canvas in different positions

我想在canvas、The template would be something like this

上画一些文字和图片

我设法画了文字,但我一直在画图像。

这是我所做的

Bitmap bmp = Bitmap.createBitmap(949, 300, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bmp);

        TextPaint tp = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        tp.setColor(0xFF000000);
        tp.setTextSize(15 * getApplicationContext().getResources().getDisplayMetrics().density + 0.5f);
        tp.setShadowLayer(2, 0.5f, 0.5f, Color.BLACK);
        StaticLayout sl = new StaticLayout("This is",
                tp, 300, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false);
        StaticLayout sm = new StaticLayout("This is",
                tp, 300, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false);


        canvas.save();
        canvas.translate(50, 20); //position text on the canvas
        sl.draw(canvas);
        canvas.restore();

        canvas.save();
        canvas.translate(50, 90); //position text on the canvas
        sm.draw(canvas);
        canvas.restore();

        ImageView iv = (ImageView) findViewById(R.id.iv);
        iv.setImageBitmap(bmp);

<ImageView
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/border_ui" />

知道如何绘制图像吗?

ImageView iv = (ImageView) findViewById(R.id.iv);
iv.setImageBitmap(bmp);
iv.draw(canvas); // Pass canvas to view to draw