How to disable click(Touch) in a Webview?

Asked

Viewed 98 times

0

The application is simple. Show a webview from an external website. The problem I want to disable clicks, I do not want to give the user to navigate, I just want to look at the initial page set.

package br.com.spitzer.webview;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.support.v7.app.AlertDialog;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;



public class ViewTabelasE extends Activity {      


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_tabelas_e);
        WebView wv = (WebView) findViewById(R.id.webView1);
        WebSettings ws = wv.getSettings();
        ws.setJavaScriptEnabled(false);
        ws.setSupportZoom(false);
        wv.setWebViewClient(new WebViewClient());
        wv.loadUrl("http://www.google.com");


    }

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_menos2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible"
    android:background="@color/colorPrimary"
    tools:context="br.com.spitzer.webview.ViewTabelasE">

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="-390dp"
        android:layout_marginTop="-200dp"
        android:clickable="false">

    </WebView>




</RelativeLayout>

android:clickable="false" does not work.

1 answer

0

Try to use:

webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
    return true;
}});

This disables the touch.

Source: Question Stack (English)

  • disables, but disables everything, I want it to look all etc "pull down the scrollbar" zoom, etc

  • Take a look at the answer to that question, maybe that’s exactly what you want: https://stackoverflow.com/questions/19426742/dont-navigate-to-other-pages-in-webview-disable-links-and-references

Browser other questions tagged

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