I have custom scrollview written which is working fine without stylus from Tablets. When using Tablet stylus this customScrollview is allowing stylus to perform scrolling even when Scrolling is disabled.
public class CustomScrollView extends ScrollView {
private boolean enabled = false;
public CustomScrollView(Context context) {
super(context);
}
public CustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean getEnabled() {
return this.enabled;
}
}
Overriding onInterceptHoverListener Did the trick. Now the Stylus onhover scroll is handled if scrollview is enabled,the same is not handled once the scrollview enabled = false.
public class CustomScrollView extends ScrollView {
private boolean enabled = false;
public CustomScrollView(Context context) {
super(context);
}
public CustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public boolean onInterceptHoverEvent(MotionEvent event) {
if (this.enabled)
{
return false;
}
else
{
return true;
}
}
public boolean getEnabled() {
return this.enabled;
}
}