Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:08:32+00:00 2026-06-18T06:08:32+00:00

I have a webView and on this webView a button . I catch a

  • 0

I have a webView and on this webView a button. I catch a touch event on the webview like this : webView.setOnTouchListener(this);.

@Override
    public boolean onTouch(View v, MotionEvent event) {
        if (ADS_VIDEO.contains(v.getId()) && v.getId() == R.id.webView
                && event.getAction() == MotionEvent.ACTION_DOWN) {
            intentVideo = new Intent(getBaseContext(),
                    AdVideoActivity.class);
            startActivity(intentVideo);
        }
        return false;
    }

I also have this for my button :

 button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
         webView.setVisibility(View.GONE);
         button.setVisibility(View.GONE);
        }
    });

My problem is when I click on the button, the event for the webView is launched and not the event linked to the button.

Update :

xml :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dip"
android:id="@+id/relativeForWeb" >

<ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:contentDescription="@string/descr_image"
     />

<ProgressBar
    android:id="@+id/loading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:visibility="gone" />

<Button
    android:id="@+id/bt"
    android:layout_width="42dip"
    android:layout_height="42dip"
    android:text="x" 
    android:background = "@drawable/roundedbutton"/>


<WebView  
    android:id="@+id/webView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

/>

</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:08:33+00:00Added an answer on June 18, 2026 at 6:08 am

    Because the WebView comes after the Button in your layout.xml, it lays above it (RelativeLayout sets the z-order of its views depending on the order they are in the layout.xml).
    And because the webview is above the button, it gets the touch event first and consumes it.

    Simply move the webview declaration before the button declaration in your layout.xml and you should be good.

    Like so:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dip"
    android:id="@+id/relativeForWeb" >
    
    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:contentDescription="@string/descr_image"
         />
    
    <ProgressBar
        android:id="@+id/loading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="gone" />
    
    <WebView  
        android:id="@+id/webView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    
    />
    
    <Button
        android:id="@+id/bt"
        android:layout_width="42dip"
        android:layout_height="42dip"
        android:text="x" 
        android:background = "@drawable/roundedbutton"/>
    
    
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have a webView that contains the FB like button. JS
I have an back button(Image Button) on the webview. I want to make this
So I have a view containing a web view with HTML content. This is
I have a WebView at the bottom of view in ViewPager ... When I
I have a webview which I would like to remove the elasticity from. As
I have a WebView. I'd like to show some page from my server, but
In my iPhone app, I have this button, that opens a webcal:// URL in
I have a webview that loads a webpage. I also have a reload button.
I have a a WebView and a Button above the top-right corner of it
So I have a webview I'd like to display as a dialog. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.