Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XXHDPI Support for pan gestures #63

Open
wvdvegt opened this issue Dec 7, 2017 · 0 comments
Open

XXHDPI Support for pan gestures #63

wvdvegt opened this issue Dec 7, 2017 · 0 comments

Comments

@wvdvegt
Copy link

wvdvegt commented Dec 7, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant