How to disable Clicking of WebView?

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

Using android:clickable="false" does not disable touch events.

Share:
15,120
Qamar Zaman
Author by

Qamar Zaman

Updated on June 06, 2022

Comments

  • Qamar Zaman
    Qamar Zaman almost 2 years

    I have Linear Layout which contains Only WebView. What i want to do is to disable the click in Webview, means I want the event to be called associated with RelativeLayout bg_stepsContainer. I've used the android:clickable="false" Here is code

     <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:minHeight="30dp" 
                        android:layout_marginLeft="5dp"
                        android:layout_marginRight="5dp"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:id="@+id/bg_stepsContainer"
                        >
    
                    <LinearLayout
                        android:id="@+id/stepslcontainer"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true"
    
                        android:clickable="false"
                        android:focusable="false"
                        android:focusableInTouchMode="false" >
    
                        <WebView
                            android:id="@+id/bg_stepsToReproduce"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:clickable="false"
                            android:focusable="false"
                            android:focusableInTouchMode="false" 
    
                            android:textColor="@color/solid_black" />
    
                        </LinearLayout>
                        <ImageView
                            android:id="@+id/stepsArrow"
                            android:layout_width="10dp"
                            android:layout_height="10dp"
                            android:layout_alignParentRight="true"
                           android:clickable="false"
                            android:layout_marginRight="10dp"
                            android:layout_marginLeft="10dp"
                            android:layout_centerVertical="true"
                            android:src="@drawable/ic_right_arrow" />
    
     </RelativeLayout>
    

    Any Suggestions are Appreciated!

  • ubuntudroid
    ubuntudroid over 6 years
    @GowthamanM just remove the OnTouchListener from the webview.
  • levi
    levi over 5 years
    how you can remove the OnTouchListener from the webview ?