I have a canvas and I am drawing bitmap into it and moving that bitmap using onTouchEvent method. My problem is that the bitmap I move sometimes go out of the开发者_JS百科 canvas region so how to solve this problem related to boundry of canvas. Please help me out on this and Thanks in advance.
When you move the finger over the screen, you set the x,y drawing coordinates for your bitmap. Since you can know the size of the canvas from onSizeChanged method, you just need to make an if statement which will change the drawing coordinates of this bitmap only if the finger is within the area you want.
From the distance of current position and the base position calculate from your algorithm, you could able to manage this problem. It's only your algorithm problem.
精彩评论