Scroll Webview does not appear

Asked

Viewed 163 times

0

I created my first application on android being that it was (Webview) but when I enter the application, my site is fixed inside, no 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"/>
  • How’s your layout file?

  • <WebView xmlns:android="http://schemas.android.com/apk/res/android"&#xA; android:id="@+id/myWebView"&#xA; android:layout_width="fill_parent"&#xA; android:layout_height="fill_parent"&#xA; android:scrollbars="none"/>

1 answer

0


What’s going on is that your WebView is set not to have scroll. You have to remove the line android:scrollbars="none" of 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 attribute settings scrollbars:

  • android:scrollbars="vertical": enabling scroll upright
  • android:scrollbars="horizontal": enabling scroll horizontally
  • android:scrollbars="none": disable scroll
  • I have the following problem now, when I change the position of the mobile phone, the webview of the Reload and back to the login page, you know what may be happening?

  • @Evertongouveia I suggest you ask another question, because it has nothing to do with this. But in advance, it seems to be a simple thing to solve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.