Java – Multiple color/stroke gestures and continuous drawing in the same GestureOverlayView

Multiple color/stroke gestures and continuous drawing in the same GestureOverlayView… here is a solution to the problem.

Multiple color/stroke gestures and continuous drawing in the same GestureOverlayView

I’ve seen a lot of examples of drawing using gestures. My request is that I want to draw multicolor and multi-stroke gestures in the same GestureOverlayView. For more clarity, take a look at the image below.

enter image description here

If the user selects different colors and different strokes, the drawing should be the respective colors/strokes. Now, it draws different colors and different stroke gestures, but if I choose a different color or a different stroke, the previously drawn gesture also takes a new color or a new stroke.

A similar question was answered< a href="https://stackoverflow.com/questions/9383026/how-to-persist-the-gestures-of-the-gestureoverlayview/9384343#9384343" rel="noreferrer noopener nofollow" > Here, but with the same problem.

Please make suggestions.

<android.gesture.GestureOverlayView
       android:id="@+id/signaturePad"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@android:color/white"
       android:eventsInterceptionEnabled="false"
       android:fadeEnabled="false"
       android:fadeOffset="122000"
       android:gestureStrokeLengthThreshold="0.1"
       android:gestureStrokeWidth="6"
       android:gestureStrokeType="multiple"
       android:orientation="vertical" >

</android.gesture.GestureOverlayView>

In Java code, change the color code

mGestureOverlayView.setGestureColor(Color.BLUE);

Thank you.

EDIT: Want to do the same with Canvas and start with here Get the code. It draws multiple lines, but the problem is that when I change the color/stroke, the recently drawn line also has a new color/stroke.
Please suggest what went wrong here.

Edit (answer): Finally got the solution. Look at this link.

Related Problems and Solutions