xamarin/Xamarin.Forms

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

开放

#3,469 创建于 2018年8月2日

 (2 条评论) (0 个反应) (0 位负责人)C# (1,926 个派生)batch import
e/8 :clock8:help wantedi/highinactivep/Androidt/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南