如何将可绘制图像移动到 android 中 canvas 的底部

How to move a drawable image to bottom of canvas in android

在我的应用程序中,我创建了一个 PDF 文件,我已经使用 canvas 绘制文本和图像,我的问题是,我想在 PDF 页面的底部添加图像,这样我使用过此代码;

 Drawable icon = ContextCompat.getDrawable(context,R.drawable.book);

        icon.setBounds(80, 60, 180, 200);
        icon.draw(canvas2);

使用这段代码,我可以在 canvas 上绘制我的应用程序图标,我怎样才能将它移到我的 pdf 文档的底部,有什么方法吗??有人能帮忙吗??

int halfWidth = Width/2;
int halfHeight = Height/2
Rect dstRectForRender = new Rect( X - halfWidth, Y - halfHeight, X + halfWidth, Y + halfHeight );
canvas.drawBitmap ( someBitmap, null, dstRectForRender, null );