I found the answer from this question
In case the link is dead, I copied the code here:
Make a new class with this exact code, it will prevent MapView to receive any other gesture aside of map-related gesture. Don't forget to add your package
and import
(CTRL+SHIFT+O) above these code
public class CustomViewPager extends ViewPager {
public CustomViewPager(Context context) {
super(context);
}
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
if (v instanceof MapView) {
return true;
}
return super.canScroll(v, checkV, dx, x, y);
}
}
Then in main.xml
change the <android.support.v4.view.ViewPager ... />
into this:
<com.yourPackage.CustomViewPager
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main" />
Thanks to Jorge Aguilar for the answer in that question!