Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Optimise horizontal swipe in a ViewPager #9561

Closed

Description

@tobrun

It's currently hard to pan the map horizontally because the wrapping ViewPager always consumes this touch event. Ideally we limit switching pages only to the edge of the ViewPager. We should look into using something as onTouchIntercept or at least provide an workaround for in our examples.

ezgif com-video-to-gif 71

Activity

  1. added
    Android
    good first issue
    on Jul 20, 2017
  2. tobrun commented on Jul 24, 2017

    @tobrun
    MemberAuthor

    we could try resolving this issue using android.support.v4.widget.NestedScrollView.

  3. tobrun commented on Jul 25, 2017

    @tobrun
    MemberAuthor

    A workaround for end users is using a custom ViewPager and providing the following implementation:

    package com.mapbox.mapboxsdk.testapp.view;
    
    import android.content.Context;
    import android.support.v4.view.PagerTabStrip;
    import android.support.v4.view.ViewPager;
    import android.util.AttributeSet;
    import android.view.SurfaceView;
    import android.view.View;
    
    public class MapViewPager extends ViewPager {
    
      public MapViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
      }
    
      @Override
      protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
        return v instanceof SurfaceView || v instanceof PagerTabStrip || (super.canScroll(v, checkV, dx, x, y));
      }
    }

    ezgif com-video-to-gif 75

  4. tobrun commented on Jul 26, 2017

    @tobrun
    MemberAuthor

    Valid workaround provided, don't feel this is a requirement to fix from SDK side. Closing.

  5. ArnyminerZ commented on May 3, 2020

    @ArnyminerZ

    Is there any workaround using ViewPager2? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Androidgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions