是否可以将图像设置为绘制对象而不是颜色?

Ash*_*rma 1 android view paint rect

 Paint mPaint = new Paint();
 mPaint.setStyle(Style.FILL);
 mPaint.setColor(Color.Red);
 canvas.drawRect(mRedPaddleRect, mPaint);
Run Code Online (Sandbox Code Playgroud)

这里,mRedPaddleRect是一个使用Rect形成的Rectangle,而不是设置它我想要设置一个Image的颜色.

如何才能做到这一点?

任何帮助,将不胜感激.

谢谢.

Ash*_*rma 5

这就是我做到的,我简直不敢相信

       Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.racquet);
       canvas.drawBitmap(bitmap, null, mRedPaddleRect, mPaint);
Run Code Online (Sandbox Code Playgroud)

希望这也有助于其他人.