maplibre / maplibre/maplibre-native

Android: two-finger tilt sensitivity depends on display density

Open
#4,635 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

android
Dominant language
C++
Stars
2.2k
Forks
616
Avg merge
1d 23h
Merged PRs (30d)
43

Description

What happened?

Android calculates tilt using 0.1° per physical pixel of vertical finger movement. This makes the same drag distance in dp produce different pitch changes depending on display density.

For example, after gesture recognition, a 100 dp drag produces:

  • Density 1: 10° of pitch change.
  • Density 3: 30° of pitch change.

Expected: equivalent drag distances in dp should produce equivalent pitch changes.

Source evidence

ShoveGestureDetector calculates the centroid displacement directly from MotionEvent.getY(), in pixels.

MapGestureDetector multiplies this displacement by SHOVE_PIXEL_CHANGE_FACTOR (0.1) without normalizing for display density.

For comparison, iOS uses 0.5° per UIKit point, independent of screen scale.

I personally found 0.5° to be a bit fast, so made MapLibre Compose default to 0.3°/Dp on all targets.

Environment

Source inspection of main at c82c14f9710a861e0a4cef335eff311eea50cd86.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ShoveGestureDetector.java, where centroid displacement comes from MotionEvent.getY(), then trace MapGestureDetector.java and SHOVE_PIXEL_CHANGE_FACTOR. Compare the Android calculation with the iOS point-based behavior and verify that equivalent drag distances in dp produce equivalent pitch changes across display densities.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.