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

Optimise horizontal swipe in a ViewPager #9561

Closed
tobrun opened this issue Jul 20, 2017 · 4 comments
Closed

Optimise horizontal swipe in a ViewPager #9561

tobrun opened this issue Jul 20, 2017 · 4 comments
Labels
Android Mapbox Maps SDK for Android good first issue Good for newcomers

Comments

@tobrun
Copy link
Member

tobrun commented Jul 20, 2017

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

@tobrun tobrun added Android Mapbox Maps SDK for Android good first issue Good for newcomers labels Jul 20, 2017
@tobrun
Copy link
Member Author

tobrun commented Jul 24, 2017

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

@tobrun
Copy link
Member Author

tobrun commented Jul 25, 2017

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

@tobrun
Copy link
Member Author

tobrun commented Jul 26, 2017

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

@tobrun tobrun closed this as completed Jul 26, 2017
@ArnyminerZ
Copy link

Is there any workaround using ViewPager2? Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants