【问题标题】:Android Draw Bitmap to CanvasAndroid 将位图绘制到画布上
【发布时间】:2015-02-15 20:32:06
【问题描述】:

我正在尝试在自定义SurfaceView 中将Bitmap 绘制到Canvas,但它没有出现在任何地方。

SurfaceView,我正在使用:

//in the constructor
Bitmap leftUp = BitmapFactory.decodeResources(R.drawable.leftup);
leftCurrent = leftUp; //it's a button - leftUp and leftDown

//in my drawing method
canvas.drawBitmap(leftCurrent, controlsWidth, controlsHeight, new Paint());

它运行正常,没有错误,但没有任何显示。有人有什么想法吗?

【问题讨论】:

  • 你的surfaceview有宽度和高度吗? ,你检查过 controlsWidth 和 controlsHeight 不是 0 吗?
  • 你想在另一个图像上还是在空白视图上绘制它?

标签: android android-canvas


【解决方案1】:

问题在于您绘制传递给 drawBitmap 方法的对象。它必须正确配置。看看this 回答。

【讨论】:

  • 此链接可能会提供问题的答案,但最好为链接提供更多上下文。如果链接失效,这个答案将毫无用处。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-14
  • 2012-11-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-06
  • 1970-01-01
相关资源
最近更新 更多