WebView Scroll does not appear

0

I created my first application on the android being that it was (WebView) but when I enter the application, my site is fixed inside, without scroll.

My code is:

package com.sirseni.simpleandroidwebviewexample;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView myWebView = (WebView) findViewById(R.id.myWebView);
        myWebView.loadUrl("http://meulink.com/");

        myWebView.setWebViewClient(new MyWebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return false;
            }
        });
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

    }

    // Use When the user clicks a link from a web page in your WebView
    private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (Uri.parse(url).getHost().equals("http://meulink.com/")) {
                return false;

            }

            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
    }
}

Layout: activity_main.xml

<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/myWebView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="none"/>
    
asked by anonymous 05.06.2017 / 15:12

1 answer

0

What is happening is that your WebView is set to no scroll . You must remove the android:scrollbars="none" line from your * WebView *.

See how it should look:

<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/myWebView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"/>

See the definitions of the scrollbars attribute:

  • android:scrollbars="vertical" : enable scroll vertically
  • android:scrollbars="horizontal" : enable scroll horizontally
  • android:scrollbars="none" : disables scroll
05.06.2017 / 16:10