1.
com.example.beijing.view Package; Import android.content.Context; Import android.support.annotation.NonNull; Import android.support.annotation.Nullable; Import android.support.v4.view.ViewPager; Import android.util. AttributeSet; Import android.view.MotionEvent; / ** * oF: created by $ {} Pingshi Jiang * time: 2019/6/16 ON * QQ number: 764760811 * micro-channel: 18785461074 * Function: custom can not slide a ViewPager * / public class NoScrollViewPager the extends a ViewPager { / ** * generally instantiation code * @param context * / public NoScrollViewPager (@NonNull the context context) { Super (context); } / ** * Use the class in the layout file when the class is instantiated with the constructor, this method can not be less, otherwise collapse * system because it is prescribed, be sure to pass these two parameters, * then should touch event returns to true * @param context * @param attrs * / public NoScrollViewPager (@NonNull the context context, AttributeSet attrs @Nullable) { Super (context, attrs); } / ** * rewrite touch event consumed * @param ev @return * * / @Override public Boolean onTouchEvent (the MotionEvent EV) { return to true; } }
2.
** * OF: created by $ {} Pingshi Jiang * Time: 2019/6/14 ON * QQ number: 764760811 * micro-channel: 18785461074 * Function: Body Fragment * / public class ContentFragment the extends BaseFragment { // @ViewInject (R.id .viewpage) // initialize control Private NoScrollViewPager ViewPage; .........
}
3.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.example.beijing.view.NoScrollViewPager android:id="@+id/viewpage" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> ........