如何在画布上绘制多个位图
我在使用画布功能时遇到问题,用画布绘制 1 个位图没有问题,但一旦添加第二个位图,它就只绘制最后一个位图,而不显示两者。 请帮忙。这是我的代码。 我的目的是在屏幕上独立地对这两个不同的位图进行动画处理。
@Override
protected void onDraw(Canvas canvas) {
football = BitmapFactory.decodeResource(getResources(),
R.drawable.ballicon);
receiver = BitmapFactory.decodeResource(getResources(),
R.drawable.rec);
canvas.drawBitmap(football, translate, null);
canvas.drawBitmap(receiver, translate, null);
Matrix m = canvas.getMatrix();
Log.d(DEBUG_TAG, "Matrix: " + translate.toShortString());
Log.d(DEBUG_TAG, "Canvas: " + m.toShortString());
}
谢谢
I am having trouble with the canvas function, I have no problem drawing 1 bitmap with the canvas but as soon as I add a 2nd bitmap, it only draws the last bitmap, does not show both.
please help. here is my code.
My intent, is to then animate these 2 different bitmaps independently on the screen.
@Override
protected void onDraw(Canvas canvas) {
football = BitmapFactory.decodeResource(getResources(),
R.drawable.ballicon);
receiver = BitmapFactory.decodeResource(getResources(),
R.drawable.rec);
canvas.drawBitmap(football, translate, null);
canvas.drawBitmap(receiver, translate, null);
Matrix m = canvas.getMatrix();
Log.d(DEBUG_TAG, "Matrix: " + translate.toShortString());
Log.d(DEBUG_TAG, "Canvas: " + m.toShortString());
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个用于使用多个位图进行绘制的画布视图
Here is a canvasview for drawing with multiple bitmaps