android - How to lock ViewPager to allow only a single page swipe at once -
by default, when swipe on viewpager, can swipe on many pages can until finger reaches end of screen. so, possible force viewpager allow 1 page change no matter how user swipes?
this mean swiping on pager until finger reaches end of screen:
and mean locking viewpager allow single page swipe @ time:
thanks.
okay, think answer is: extend viewpager
, override ontouchevent(motionevent ev)
.
private rect viewrect = new rect(); @override public boolean ontouchevent(motionevent event) { gethitrect(viewrect); if (viewrect.contains( math.round(view.getx() + event.getx()), math.round(view.gety() + event.gety()))) { // touch inside, normal behavior return super.ontouchevent(event); } else { // touch outside, consume event & nothing return true; } }
unfortunately, don't have time test out right now, i'll update later.
Comments
Post a Comment