我想在画布,Android中使用drawBitmap()
将两个位图相邻放置。如何在Android canvas中使用drawBitmap来定位位图
我的onDraw()
功能。
protected void onDraw(Canvas canvas) {
if (currentState == openedState) {
fruit1Bitmap = ApplicationServices.textureManager.bitmap[fruitId[0]];
fruit2Bitmap = ApplicationServices.textureManager.bitmap[fruitId[1]];
fruit3Bitmap = ApplicationServices.textureManager.bitmap[fruitId[2]];
src.set(0, 0, fruit1Bitmap.getWidth(), fruit1Bitmap.getHeight());
dst.set(0,0, this.getWidth()/2, this.getHeight()/2);
src1.set(0, 0, fruit2Bitmap.getWidth(), fruit2Bitmap.getHeight());
dst1.set(fruit1Bitmap.getWidth() , 0, this.getWidth()/2, this.getHeight()/2);
canvas.drawBitmap(fruit1Bitmap, src, dst, null);
canvas.drawBitmap(fruit2Bitmap, src1, dst1, null);
}
}
它是在类public class Dhakkan extends ImageButton
。
当前结果
我想要得到它,以显示彼此相邻两种水果。那么如何将它们放置在ImageButton
之内。
是的!感谢它的工作! – 2015-02-25 05:32:34