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

  • Home
  • SEARCH
  • 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 8297957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:35:37+00:00 2026-06-08T15:35:37+00:00

I have another question with Android. Today I’m trying to use the WebView to

  • 0

I have another question with Android. Today I’m trying to use the WebView to display an image. The image has a dimension larger than the view which make the user able to scroll. Now, what I want to achieve is when the user touches somewhere on the image (in the webview), an event will be triggered and the coordinates of the touch will be stored.

When I try to do this using onClick in the xml layout, all I get as a parameter is the view object that trigger the on click event. Here is my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView 
    android:id="@+id/upperview" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:layout_weight="1"
    android:onClick="imageClicked" />
<WebView 
    android:id="@+id/lowerview" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:layout_weight="1" />

</LinearLayout>

Now here is my activity:

public class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView upperview = (WebView) findViewById(R.id.upperview);
    upperview.getSettings().setBuiltInZoomControls(true);
    upperview.loadUrl("file:///android_asset/texture.png");

    WebView lowerview = (WebView) findViewById(R.id.lowerview);
    String htmlstring = "<h1>Header</h1><p>This is HTML text<br /><i>Formatted in italics</i></p>";
    lowerview.loadData(htmlstring, "text/html", "utf-8");
}

public void imageClicked(View view) {

}
}

Now, there still no functions inside the imageClicked method because I wasn’t sure where to find the coordinates. Am I doing this wrong? I was thinking maybe the onClick attribute in the xml layout only correspond to a generic click/touch in the webview. Is there an alternative to achieve what I want? Thanks in advance 🙂

  • 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-08T15:35:41+00:00Added an answer on June 8, 2026 at 3:35 pm

    Have you tried with onTouch event instead of onClick. onTouch event gives you the x and y coordinates. check here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have another question :(. I'm trying to download multiple files for my application.
I have another simple question about Node. I'm trying to make a simple http
i have another question on getting my XML serialization neat, which i can't seem
I have another question and I can't seem to find anything on Google. What
Okay, so I have another question on a prolog homework problem I am struggling
I have another Richfaces question which may seem rather weird. I am developing a
i have another (probably unanswered) question about map views. I have a map view
I have recently posted another question which straight away users pointed me in the
I have read an answer to another question here on Stack Overflow. Let me
Another question related to this one . I have a List<SortableObjects> that is the

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.