How to draw a picture on canvas when dragging fingers

My Android application allows the user to open an image, create tags in certain areas (visual key), for which they can separately add notes and share in their team.

eg. To complete the construction plan, the application allows you to open the proposed plan in the form of a bitmap, where management can propose a modification by marking specific sections and add relevant notes.

The requirement is that the user must have a choice in order to select a template to be drawn on his finger.

What are the options that Android offers for drawing a template?

For reference, just look at this following image. enter image description here

I want to draw one of the above drawings on my finger.

+6
source share
2 answers

You can use the GestureDetector class, which is more flexible for detecting TouchEvents. You can refer to http://developer.android.com/training/gestures/detector.html for a better explanation.

0
source

With this code, you can draw with your finger in the canvas.

Then add you must add a shader to the Paint object to draw patterns like yours.

mPatternBitmap = BitmapFactory.decodeResource(getResources(), pPatternId); mBitmapShader = new BitmapShader(mPatternBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); mPaint.setShader(mBitmapShader); 

Where pPatternId is the image identifier of your template from res.

0
source

Source: https://habr.com/ru/post/950156/


All Articles