content: package com.bihe0832.android.lib.ui.viewpager;
  
  import android.content.Context;
  import android.util.AttributeSet;
  import android.view.MotionEvent;
  
  import androidx.viewpager.widget.ViewPager;
  
  /**
   * @author zixie code@bihe0832.com
   * Created on 2022/7/29.
   * Description: Description
   */
  public class NoScrollViewPager extends ViewPager {
  
      private boolean scrollable = false;
  
      public NoScrollViewPager(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public NoScrollViewPager(Context context) {
          super(context);
      }
  
      public void setScrollable(boolean scrollable) {
          this.scrollable = scrollable;
      }
  
      public boolean isScrollable() {
          return scrollable;
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent ev) {
          if (scrollable) {
              return super.onTouchEvent(ev);
          } else {
              return false;
          }
      }
  
      @Override
      public boolean onInterceptTouchEvent(MotionEvent ev) {
          if (scrollable) {
              return super.onInterceptTouchEvent(ev);
          } else {
              return false;
          }
      }
  }