Android-Horizontal-Swipe-WebView
Android-Horizontal-Swipe-WebView copied to clipboard
Last page issue
When I swipe to the last page, it doesn't scroll to the end of it. I have to make about 3 swiping moves to see the whole last page. And then, after I swipe back, it goes back for 3 pages instead of 1.
Thank you for your work.
when you test with long text, the javascript syntax return wrong page count.
Did you find any solution for it @vaziliybober and @paulsenjs ???
No, @Jothi-Vtech. I decided not to use this code. And I didn't find an alternative, so I just don't use the animation, which isn't a big loss. You get used to it immediately.
@vaziliybober I found a solution for this,
this.setWebViewClient(new WebViewClient() {
public void onPageFinished(@NonNull WebView view, @NonNull String url) {
String varMySheet = "var mySheet = document.styleSheets[0];";
String addCSSRule = "function addCSSRule(selector, newRule) {"
+ "ruleIndex = mySheet.cssRules.length;"
+ "mySheet.insertRule(selector + '{' + newRule + ';}', ruleIndex);"
+ "}";
String insertRule1 = "addCSSRule('html', 'padding: 0px; height: "
+ (view.getMeasuredHeight() / context.getResources().getDisplayMetrics().density)
+ "px; -webkit-column-gap: 0px; -webkit-column-width: "
+ view.getMeasuredWidth() + "px;')";
view.loadUrl("javascript:" + varMySheet);
view.loadUrl("javascript:" + addCSSRule);
view.loadUrl("javascript:" + insertRule1);
}
});
This worked for me. Instead of that customized webview, I tried this. I think it's too late but it may help someone :)
@Jothi-Vtech So you just replaced the webViewClient code in the original source (the one that calls injectJavascript ) with this? It doesn't seem to work for me, I tried a simple long HTML text and this breaks horizontal scroll completely.