Maui Android how to get position of the tap gesture position?

Dung Huynh 121 Reputation points
2024-04-12T13:34:30.37+00:00

I am trying to develop an Maui Android app that lets user draw a line on a view using tap gesture.

Could you tell me how to get the position of the tap gesture from user so that I can draw a line from that?

Thanks.

Dung Huynh.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,959 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 69,306 Reputation points Microsoft Vendor
    2024-04-15T05:28:22.9133333+00:00

    Hello,

    Could you tell me how to get the position of the tap gesture from user so that I can draw a line from that?

    If you use tap gesture to get the position from user, you can obtain by calling the GetPosition method on a TappedEventArgs object. The GetPosition method accepts an Element? argument, and returns a position as a Point?

    See:Get the gesture position

    By the way, if you want to draw a line. Use Skisharp and effect is a good choice. You can refer to this document: Invoking Events from Effects, it is Xamarin document, but it could be used in the MAUI.

    If you use Effect in MAUI, please check the Reuse effects in .NET MAUI.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful