android - Make WebView's list scrollable -


i have page looks this*:

<scrollview>   <webview/>   <webview/>   <webview/> </scrollview> 

* not actual layout, enough question , makes problem clearer.

i don't know how webview looks because can variable. webview can contain scrollable list.

i want achieve scrolling behaviour:

enter image description here

these 2 webviews (the 1 blue header , 1 green header). want scroll list in blue webview when i'm dragging in list. if touch anywhere else (for example on blue or green header), want scroll in scrollview.

my attempt solve customrenderer webview, found in this thread in xamarin forums:

protected override void onelementchanged(elementchangedeventargs<webview> e) {     base.onelementchanged(e);      if (e.oldelement != null)     {         control.touch -= control_touch;     }      if (e.newelement != null)     {         control.touch += control_touch;     } }  void control_touch(object sender, toucheventargs e) {     // executing prevent scrolling intercepted parent views     switch (e.event.action)     {         case motioneventactions.down:             control.parent.requestdisallowintercepttouchevent(true);             break;         case motioneventactions.up:             control.parent.requestdisallowintercepttouchevent(false);             break;     }     // calling allow scrolling event executed in webview     control.ontouchevent(e.event); } 

this job, can scroll in list inside of webview now, won't scroll in scrollview anymore if tap anywhere else in webview.

so tried check height of inner list:

case motioneventactions.down:     if (computeverticalscrollrange() > measuredheight)         control.parent.requestdisallowintercepttouchevent(true);     break; case motioneventactions.up:     if (computeverticalscrollrange() > measuredheight)         control.parent.requestdisallowintercepttouchevent(false);     break; 

measuredheight height of webview. computeverticalscrollrange() return same height measuredheight tho. 1 possible solution height of inner list in webview, don't know how can (i'm new android). , maybe, there other solutions this.

for code control.parent.requestdisallowintercepttouchevent(true);, need make sure control.parent scrollviewer.

afaik, implement view each platform, uses renderers, control.parent here webviewrenderer, think need possible this:

control.parent.parent.parent.parent.requestdisallowintercepttouchevent(true); 

the real problem when set true or false, may example modify control_touch event this:

private void control_touch(object sender, toucheventargs e) {     var viewheight = control.measuredheight;     var height = (int)math.floor(control.contentheight * control.scale);     switch (e.event.action)     {         case motioneventactions.down:             downy = e.event.gety();             maction = actionstate.none;             control.parent.parent.parent.parent.requestdisallowintercepttouchevent(true);             break;          case motioneventactions.move:             upy = e.event.gety();             var delta = downy - upy;             if (math.abs(delta) > min_distance)             {                 if (delta < 0)                 {                     maction = actionstate.tb;                     //top reached                     if (control.scrolly == 0)                     {                         control.parent.parent.parent.parent.requestdisallowintercepttouchevent(false);                     }                 }                 else if (delta > 0)                 {                     maction = actionstate.bt;                      //bottom reached                     if (control.scrolly + viewheight + 5 >= height)                     {                         control.parent.parent.parent.parent.requestdisallowintercepttouchevent(false);                     }                 }             }             break;          case motioneventactions.up:             control.parent.parent.parent.parent.requestdisallowintercepttouchevent(true);             break;     }     control.ontouchevent(e.event); } 

i used 2 custom webview test demo, idea disable scrolling of webview when reached top , been scrolling top bottom, or vice versa. may have try.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -