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

Commit

Permalink
[android] - use custom viewpager to allow horizontal swiping
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jul 25, 2017
1 parent a178248 commit de14815
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

public static class MapFragmentAdapter extends FragmentPagerAdapter {
static class MapFragmentAdapter extends FragmentPagerAdapter {

private static int NUM_ITEMS = 3;

public MapFragmentAdapter(FragmentManager fragmentManager) {
MapFragmentAdapter(FragmentManager fragmentManager) {
super(fragmentManager);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.view.ViewPager
<com.mapbox.mapboxsdk.testapp.view.MapViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -17,6 +17,6 @@
android:paddingBottom="4dp"
android:paddingTop="4dp"/>

</android.support.v4.view.ViewPager>
</com.mapbox.mapboxsdk.testapp.view.MapViewPager>

</RelativeLayout>

0 comments on commit de14815

Please sign in to comment.