[android] - use custom viewpager to allow horizontal swiping
This commit is contained in:
committed by
Tobrun
parent
a178248139
commit
de14815a29
@@ -31,11 +31,11 @@ public class ViewPagerActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
@@ -17,6 +17,6 @@
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="4dp"/>
|
||||
|
||||
</android.support.v4.view.ViewPager>
|
||||
</com.mapbox.mapboxsdk.testapp.view.MapViewPager>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
Reference in New Issue
Block a user