public class MenuScrollView extends ScrollView {
/**
* Flag para controlar el bloqueo del scroll
*/
boolean lock = false;
public boolean isLocked() {
return lock;
}
public void setLock(boolean lock) {
this.lock = lock;
}
public MenuScrollView(Context context, AttributeSet attrs, int i) {
super(context, attrs, i);
this.setVerticalScrollBarEnabled(false);
this.setHorizontalScrollBarEnabled(false);
}
public MenuScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
this.setVerticalScrollBarEnabled(false);
this.setHorizontalScrollBarEnabled(false);
}
public MenuScrollView(Context context) {
super(context);
this.setVerticalScrollBarEnabled(false);
this.setHorizontalScrollBarEnabled(false);
}
/**
* Return true -> no scroll
*/
public boolean onTouchEvent(MotionEvent ev) {
if (lock) {
return true;
} else {
return super.onTouchEvent(ev);
}
}
/**
* Return false -> no scroll
*/
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (lock) {
return false;
} else {
return super.onInterceptTouchEvent(ev);
}
}
}