Skip to content
Advertisement

WebView scroll up automatically when scrolling it down little

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

    }

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.

Advertisement

Answer

try this

final WebSettings settings = mWebView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
mWebView.setVerticalScrollBarEnabled(false);
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement