xamarin/Xamarin.Forms

Android pan TotalX/TotalY bad when the gesture recognizer view is affected by layout change

Aperta

#3469 aperta il 2 ago 2018

 (2 commenti) (0 reazioni) (0 assegnatari)C# (1926 fork)batch import
e/8 :clock8:help wantedi/highinactivep/Androidt/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Description

On Android, if the view that holds a pan gesture recognizer is affected by a layout change while the pan is running, then the TotalX and TotalY values are incorrect. iOS and UWP do not have this problem. The values are less than they should be, and there is "jitter" in the values as they step up and partially back during a linear pan operation.

Others have noticed this problem:

  1. https://forums.xamarin.com/discussion/118226/android-pangesturerecognizer-jumps-back-and-forth
  2. https://forums.xamarin.com/discussion/87287/pangesturerecognizer-behaves-not-as-expected
  3. https://stackoverflow.com/questions/39458078/xamarin-pan-gesture-recognizer-not-giving-accurate-coordinates
  4. ...

I have attached a very simple iOS/Android/UWP project that illustrates the problem. The view with the pan gesture is in the bottom row of a grid, and the grid rows are resized as the pan occurs. See the screenshot below.

Steps to Reproduce

  1. Add a PanGestureRecognizer to a control on a page
  2. Handle the PanUpdated event, and update the location of the control (or its container) relative to the PanUpdated TotalX/TotalY values

Expected Behavior

On iOS and UWP, the TotalX/TotalY values in the PanUpdated event args will be correct and the affected control moves as expected

Actual Behavior

On Android, the control location lags the mouse position, and the location has "jitter"...jumps around as it moves

Basic Information

  • Version with issue: 2.x, 3.x
  • Last known good version: Unknown if any
  • Platform Target Frameworks:
    • Android: 8.1 (but the problem existed in previous versions as well)

Screenshots

Here it is in action (the jitter is not apparent in this compressed gif format):

panresizerow

Reproduction Link

PanResizeRowApp.zip

Guida contributor