Skip to content

XXHDPI Support for pan gestures #63

@wvdvegt

Description

@wvdvegt

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions