android - WebView zooming with scroll limiting -


the basic idea of want achieve able zoom content within webview, limit scrolling content doesn't show padding @ top , bottom when zoomed in. know height of padding in question.

i've extended webview class, , overridden onscrollchanged can information on when scrolling , how far. easy enough, , works fine (i.e. info need).

the problem comes when trying limit scrolling itself. can correctly limit top padding never visible, reason cannot fathom bottom not limit correctly.

here's code have within onscrollchanged:

@override     protected void onscrollchanged(int l, int t, int oldl, int oldt) {         float totalpadding = 250 * scalefactor;         float padding = totalpadding / 2;          float paddingtopstart = padding;         float paddingbottomstart = (contentheight * scalefactor) + paddingtopstart;          if (t > paddingbottomstart) {             setscrolly((int) paddingbottomstart);         } else if (t < paddingtopstart) {             setscrolly((int) paddingtopstart);         }     } 

the scale factor obtained in onscalechanged , saved class variable. totalpadding overall amount of padding (padding @ top + padding @ bottom). padding equal on both sides, hence padding = totalpadding / 2.

the paddingbottomstart assume issue. maths involved correct, yet still doesn't work. if has suggestions welcome.

turns out reason calculations weren't coming out correct because value t scroll value @ top of screen. consequently needed take account when doing calculations!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -