2
例如:myPos.getCoordX()
是0和myPos.getCoordY()
是0如何使動畫當我使用畫布
當我更新變量,myPos.getCoordX()
是50和myPos.getCoordY()
是100
然後我再次調用showPosition()
方法。
我想:當你不使用自定義視圖和的onDraw方法來更新你的畫布開始從0,0移動的動畫50,100
private void showPosition() {
Bitmap floorPlan = BitmapFactory.decodeResource(getResources(),
R.drawable.wallpaper).copy(Bitmap.Config.ARGB_4444, true);
Bitmap point = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher).copy(Bitmap.Config.ARGB_4444, true);
Bitmap PositionOnFloorplan = overlay(floorPlan, point);
// 1
PositionOnFloorplan = floorPlan.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(PositionOnFloorplan);
canvas.drawBitmap(point, (float) (myPos.getCoordX()),
(float) (myPos.getCoordY()), null);
ImageView imageView = (ImageView) findViewById(R.id.imggg);
imageView.setAdjustViewBounds(true);
imageView.setImageBitmap(PositionOnFloorplan);
}
private Bitmap overlay(Bitmap floorPlan, Bitmap point) {
Bitmap bmOverlay = Bitmap.createBitmap(floorPlan.getWidth(),
floorPlan.getHeight(), floorPlan.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(floorPlan, new Matrix(), null);
canvas.drawBitmap(point, (float) (myPos.getCoordX()),
(float) (myPos.getCoordY()), null);
return bmOverlay;
}
謝謝讓我試試 – 2015-02-22 06:06:11