我想在畫布,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