2
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/purple2" app:layout_scrollFlags="scroll|enterAlways"
        android:minHeight="56dp"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:titleTextAppearance="@style/ToolbarTitle" />
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/toolbar"
    android:orientation="vertical" >
    <WebView
        android:id="@+id/text98"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="10dp" />
</LinearLayout>

JAVA Code:

mWebView = (WebView) findViewById(R.id.text98);
// mWebView.setMinimumHeight(height);
// mWebView.setMinimumWidth(width);
WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(true);
webSettings.setSaveFormData(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAllowContentAccess(true);
webSettings.setAllowFileAccess(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
mWebView.setWebViewClient(new DefaultWebViewClient() );
mWebView.setWebChromeClient(new WebChromeClient(){});
mWebView.setHorizontalScrollBarEnabled(true);
mWebView.setVerticalScrollBarEnabled(true);
mWebView.loadUrl(url);
mWebView.setHorizontalScrollBarEnabled(true);
mWebView.setVerticalScrollBarEnabled(true);

What could the reason be? Why is scrolling not working? it works at times, but at certain other times no? Thank you for all the hellp, appreciated.Adding more lines because i am not able to get past by more code lines then post.

Eric B.
  • 4,622
  • 2
  • 18
  • 33
user3278732
  • 1,694
  • 10
  • 31
  • 67

2 Answers2

0

Nested Scrolling : If WebView is nested to a scrolling parent ( like ScrollView ), it can't scroll properly. Disable Nested Scrolling with :

android:nestedScrollingEnabled="false"

Overlapping Views : On top Overlapping Views in WebView prevent scrolling. There should be no views in WebView, if so, adjust their layout.

Check .xml file and make sure WebView is not covered & overlapped by any other view.


WebView Size : If WebView size is too small, you can't scroll. Check the height and width to display content and scroll.

If the content is too large from WebView you have to adjust, scale or zoom the settings.


WebView Settings : You've may been disabled the scroll function from settings. Enable it calling:

webView.getSettings().setScrollEnabled(true)

You also have the possibility to enable various settings like : setBuiltInZoomControls, setDisplayZoomControls and setSupportZoom.


Content Size : If WebView content is either too large or too small, scrolling can't work. The content needs to fit in WebView and have to adjust the scaling.

You also have the possibility to use methods like : setLoadWithOverviewMode & setUseWideViewPort.


WebViewClient : You have to set a WebViewClient for WebView because it can affect the scrolling. Set a WebViewClient by calling setWebViewClient in the instance.

-2

Rather than adding all the features of WebView, try adding the following code and it should work

In onCreate(),

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebClient());

And then,

public class WebClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

Hope, this resolves your issue...