在 Web 视图中,当我将页面向下滚动一点时,有些页面会自动向上滚动,但不是所有页面。为什么会出现这种情况,有什么解决方法?
以下是 XML 代码:
以下是 XML 代码:
<android.support.design.widget.CoordinatorLayout android:id="@+id/nonVideoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
这是我的代码,您可以检查一下。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
bindLayout();
mySwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
webView.reload();
}
});
CookieManager.getInstance().setCookie(url, cookie);
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
ProgressDialogHelper.showProgress(WebViewActivity.this);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, final String url) {
mySwipeRefreshLayout.setRefreshing(false);
}
});
webView.loadUrl(url);
}
这是我的Java代码,我把cookie也设置到了web视图中,并且我还设置了层类型。我查找了一下,每个人都说要设置层类型,然后这个问题就解决了,但它并没有解决。