[英]Android WebView - How to scroll WebView top after page finished?
I have a webview
app. 我有一个
webview
应用程序。 The problem I'm facing with this that it's not going up on page finished. 我所面临的问题是页面无法完成。 It should go up after the page finished but it stuck in the center.
页面完成后它应该上升,但卡在中间。 Please help me!
请帮我!
NOT WORKING PART 不工作的部分
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
@Override
public void onPageFinished(WebView view, String url) {
if (pageFinished) {
swipe.setRefreshing(false);
animate(view);
showFreeze = false;
webView.setVisibility(View.VISIBLE);
}
if (url.contains("error.html")) {
currentUrl = "https://website";
} else {
currentUrl = url;
}
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
pageFinished = true;
/////////////////////////// THIS ONE NOT WORKING /////////////////////////////
webView.pageUp(true);
}
}, 250);
super.onPageFinished(view, url);
}
});
}
@Override
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
super.doUpdateVisitedHistory(view, url, isReload);
try {
mWebView.postDelayed(new Runnable() {
@Override
public void run() {
mWebView.scrollTo(0, 0);
}
}, 200);
}catch (Exception ignored){}
}
I hope help you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.