开发者

how to get position of bitmap inside canvas?

开发者 https://www.devze.com 2023-03-22 22:07 出处:网络
i have a canvas and an image inside canvas.i need know the position of the bitmap inside the canvas. in my case x and y are not static values.how to hide this image while touch on it?

i have a canvas and an image inside canvas.i need know the position of the bitmap inside the canvas. in my case x and y are not static values.how to hide this image while touch on it? what is the advantage of using SurfaceView over View.Here i am usin开发者_如何转开发g view.

public void onDraw(Canvas canvas) {
    Bitmap imgtable = BitmapFactory.decodeResource(getResources(),R.drawable.table_01);
    int x=50;
    int y=50;
    canvas.drawBitmap(imgtable, x, y, null);
    }


You need to hold on to the values x and y as long as you need to.

So for example of you could declared x and y at the class level change them when you need to and then get their value when you need to to.

0

精彩评论

暂无评论...
验证码 换一张
取 消