【问题标题】:How to move a drawable image to bottom of canvas in android如何在android中将可绘制图像移动到画布底部
【发布时间】:2015-09-08 06:46:14
【问题描述】:

在我的应用程序中,我创建了一个 PDF 文件,并使用画布绘制文本和图像,我的问题是,我想在 PDF 页面的底部添加一个图像,所以我使用了这个代码;

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

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

使用此代码,我可以在画布上绘制我的应用程序图标,如何将其移动到我的 pdf 文档的底部,有什么方法吗?有人可以帮忙吗??

【问题讨论】:

    标签: android pdf canvas android-pdf-api


    【解决方案1】:
    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 );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-03
      • 2012-11-09
      • 2013-03-13
      • 1970-01-01
      • 2013-06-30
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多