Can I draw an image on canvas and then change its coordinates
When user clicked on the screen, I can draw image using Canvas.drawBitmap(). Then I wanna change its coordinates. But I can开发者_JAVA百科't. I tried a lot of methods. Some tutorials on the internet gives drag and drop examples. But it wants the user to press longer time. I must be able to change its coordinates instantenously. How can I do that?
You have to draw the Bitmap
again in those coordinates. Before you do so, use Canvas.drawColor(0, PorterDuff.Mode.CLEAR)
to clear the screen.
This isn't possible as you've described, however there are two possibilities to achieve your goal. First use Canvas.drawBitmap() there are a series of methods to make transformation of the image easy. Second use Canvas set transformation you can think of this as "moving/scrolling/scaling" (more exactly transforming) the viewable area of the Canvas. To move the image around hook into SurfaceView's onTouch handler.
精彩评论