-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Currently the code contains a hardcoded divide by 2 and thus pan gestures only work correctly on XHDPI screens.
To solve this i added a property and changed he signature of the NativeGestureRecognizerFactory class like:
/// <summary>
/// Gets or sets the metrics.
/// </summary>
///
/// <value>
/// The metrics.
/// </value>
public static float Density
{
get; private set;
}
/// <summary>
/// Constructor.
/// </summary>
///
/// <param name="metrics"> The metrics. </param>
public NativeGestureRecognizerFactory(float Density)
{
NativeGestureRecognizerFactory.Density = Density;
}
I corrected the hardcoded numbers in NativePanGestureRecognizer.OnMove() from
_rawTranslation.X += _velocity.X / 2;
_rawTranslation.Y += _velocity.Y / 2;
into
_rawTranslation.X += _velocity.X / NativeGestureRecognizerFactory.Density; // xxhdpi:3 xhdpi:2
_rawTranslation.Y += _velocity.Y / NativeGestureRecognizerFactory.Density; // xxhdpi:3 xhdpi:2
Finally in MainActivity of the android specific Xamarin.Forms project I changed the creation of the factory to read
As i could not find code to retrieve the Density inside the NativeGestureRecognizerFactory I opted for the static property.
Metadata
Metadata
Assignees
Labels
No labels