Forum Libraries, Components, and Plugins


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Keeping buttons "pinned" to canvas

I have been going round in circles for days now and hope someone can point me in the right direction.
I am writing an app under Xamarin.Android. I have a RelativeLayout, and inside that a SkiaSharp canvas. I am using SkiaSharp to draw an SVG plan. I then create a load of buttons programmatically (from information in an XML file), which I overlay onto the RelativeLayout (if that is the right terminology). I want to pan and zoom the plan, but the buttons need to stay in the same places RELATIVE TO THE PLAN. (This is actually quite similar to panning and zooming in Google maps, where location markers have to move with the map.)

The panning and zooming of the canvas is working well. Moving the buttons with the plan during panning is also working. Unfortunately, I simply cannot get the buttons in the right places when I start zooming. How do I know where a particular point on the plan moves to when I zoom, particularly when I zoom around a pinch point? Is there a good, well-commented example of doing this? Or maybe it is actually possible to "pin" the buttons to the SKCanvas, so their locations always change with the canvas?

I am stuck and would be grateful for some help!

Sign In or Register to comment.