android - Prevent single tap from changing SeekBar progress -
i using seekbar
in android app. when user single taps anywhere on seekbar
, progress value changed. want progress value change when user slides seekbar
thumb (just uislider
in ios).
i have tried setting clickable
property of seekbar
false didn't work. how can achieve desired behavior?
i faced same issue week , resolved using custom seekbar: following code:
public class slider extends seekbar { private drawable mthumb; public slider(context context) { super(context); } public slider(context context, attributeset attrs) { super(context, attrs); } @override public void setthumb(drawable thumb) { super.setthumb(thumb); mthumb = thumb; } @override public boolean ontouchevent(motionevent event) { if (event.getaction() == motionevent.action_down) { if (event.getx() >= mthumb.getbounds().left && event.getx() <= mthumb.getbounds().right && event.gety() <= mthumb.getbounds().bottom && event.gety() >= mthumb.getbounds().top) { super.ontouchevent(event); } else { return false; } } else if (event.getaction() == motionevent.action_up) { return false; } else { super.ontouchevent(event); } return true; }}
hope helps
Comments
Post a Comment