Reputation: 304
PREMISE: This Answer does NOT answer my question, here I ask HOW to solve this "conflict problem".
I noticed that coordinates of a view in Xamarin Forms are different from the coordinates of the same view taken in Android, something like view.X
=150 (in Xamarin Forms) correspond to view.GetX()
=900 (in Xamarin Android). This causes me a lot of problem, because I am trying to implement drag and drop using android custom renderer, in which I have to know the position of the drop zone (using myDestinationRect.Contains(myTouchX,myTouchY)
), but since the position that I have in Forms is different from the position needed in the Android custom renderer, that become impossible for me. Is there a way to like "convert" forms coordinates to android coordinates? Or are there any other solutions?
PS: in iOS everything works fine, it seems that Forms and iOS use same coordinates system.
Upvotes: 0
Views: 285
Reputation: 15021
Try to get the Device Density
first,then *density
to convert to android coordinates.
var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
var density = mainDisplayInfo.Density;
int XForms = view.X;
int XAndroid = XForms*density; //convert to android coordinates.
Upvotes: 1