How I can draw picture from drawable resources in place where I click? I have onTouch method where I get position where I click but I donlt know how I can draw picture in this coordinates.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This tutorial is helpful:
http://www.helloandroid.com/tutorials/how-use-canvas-your-android-apps-part-1
Implement what you see there to start.
Then you can update the X and Y coordinates of the image (in the tutorial they are both hardcoded to 10):
You should probably initialize mXpos and mYpos in your constructor, but I’ve done so here for simplicity in the example.
Then in Canvastutorial’s onCreate, add your OnTouchListener:
OR, depending on your needs, you can create an ArrayList of X,Y Points and add a new Point each time in onTouch, then in your onDraw method of the canvas you would iterate the canvas.drawBitmap(kangoo, 10, 10, null) line for each point.