android - HorizontalScrollView inside ScrollView - disable vertical scroll when horizontal scroll is in progress -
i have parent scrollview, holds horizontalscrollview 1 of it's child views. works perfectly, when triggering vertical scroll, horizontal scroll stops, or jittering. on top of it, there bug in ice cream sandwich not handle vertical movement on horizontalscrollview well, if inside scrollview, content smaller screen (in situation, there no vertical scrolling). jelly bean android handles properly, icecreamsandwich reason detects vertical movement, , stops horizontal scrolling.
how go making parent scrollview disable it's vertical scroll, when horizontal scroll being triggered? when scrolling horizontally horizontalscrollview, , while doing it, finger wonders bit on y axis, not want parent scrollview capture vertical motion.
any that?
just try this
horizontalscrollview hv = (horizontalscrollview)findviewbyid(r.id.myhsview); // horizontalscrollview inside scrollview hv.setontouchlistener(new listview.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { int action = event.getaction(); switch (action) { case motionevent.action_down: // disallow scrollview intercept touch events. v.getparent().requestdisallowintercepttouchevent(true); break; case motionevent.action_up: // allow scrollview intercept touch events. v.getparent().requestdisallowintercepttouchevent(false); break; } // handle horizontalscrollview touch events. v.ontouchevent(event); return true; } });
Comments
Post a Comment