WebView向下滚动时自动向上滚动 [英] WebView scroll up automatically when scrolling it down little

查看:417
本文介绍了WebView向下滚动时自动向上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Web视图中,当我向下一点滚动页面时,它会在某些页面而不是所有页面上自动滚动,但在某些页面上会自动滚动. 这是xml代码

In web view when I scroll the page little bit down then it scroll up automatically on some pages not all pages but on some pages.Why this happen and what is it solution Here is xml code

<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>

这是我的代码,您可以检查一下

Here is my code you can check this

 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视图,还设置了图层类型.我搜索到每个人都说要设置图层类型,然后这个问题解决了,但是并没有解决.

Here is my java code I set the cookie also to web view and I set also layer type. I search that everyone says to set layer type then this problem solved but it does not solved.

推荐答案

尝试一下

final WebSettings settings = mWebView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
mWebView.setVerticalScrollBarEnabled(false);

这篇关于WebView向下滚动时自动向上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆