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 9260211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:50:09+00:00 2026-06-18T12:50:09+00:00

I have created a custom webview having scroll listner and touch Listner. I am

  • 0

I have created a custom webview having scroll listner and touch Listner. I am loading the an HTML code in it, for which I have used javascript which creates img tags using for Loop.

String htnlString = "<!DOCTYPE html><html><body style = \"text-align:center\"><script type=\"text/javascript\">for(a=1;a<=10;a++)document.write('<img style=\"border-style:dotted;border-width:10px;border-color:black;\"src=\"http://shiaislamicbooks.com/books_snaps/EN183/'+a+'.jpg\" alt=\"Page Not Found\"/>');</script></body></html>";

wv.loadDataWithBaseURL(null, htnlString, "text/html", "UTF-8", null);

Now I want to get the position of img tag onTouchListner of webview.
Is there any method in webview which returns me the postion of <img> tag.

Whole code

import android.content.Context;
   import android.util.AttributeSet;
   import android.util.Log;
   import android.view.MotionEvent;
   import android.webkit.WebView;

   public class scorllableWebview extends WebView {
    private OnScrollChangedCallback mOnScrollChangedCallback;

public scorllableWebview(final Context context) {
    super(context);
}

public scorllableWebview(final Context context, final AttributeSet attrs) {
    super(context, attrs);
}

public scorllableWebview(final Context context, final AttributeSet attrs,
        final int defStyle) {
    super(context, attrs, defStyle);
}

@Override
protected void onScrollChanged(final int l, final int t, final int oldl,
        final int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);
    if (mOnScrollChangedCallback != null)
        mOnScrollChangedCallback.onScroll(l, t);
}

public OnScrollChangedCallback getOnScrollChangedCallback() {
    return mOnScrollChangedCallback;
}

public void setOnScrollChangedCallback(
        final OnScrollChangedCallback onScrollChangedCallback) {
    mOnScrollChangedCallback = onScrollChangedCallback;
}

/**
 * Impliment in the activity/fragment/view that you want to listen to the
 * webview
 */
public static interface OnScrollChangedCallback {
    public void onScroll(int l, int t);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    Log.d("onTouchEvent", event.getAction() + "");

    // I want to get the position of <img> tag here.
   // what is the method which return the <img> tag position

    return super.onTouchEvent(event);
}
 }

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-18T12:50:10+00:00Added an answer on June 18, 2026 at 12:50 pm

    this depends on what you mean by getting the coordinates of the touching.

    if you mean in android coordinates , here’s a possible solution :

    • for the onTouchListener of the webview , store the coordinate and return false , so that it would be handled normally on the websiew’s content.

    • in the javascript of touching the img tag in the webview , call a function of android using the method addJavascriptInterface (more info here ) , telling it that the img tag was touched.

    • in this function , you can take the coordinates that were saved before.

    in case you mean html coordinates , you can skip the first step , and simply pass them to the android framework.

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

Sidebar

Related Questions

I have created custom controller by following http://code.google.com/apis/maps/documentation/javascript/controls.html Is there any way to remove
I have created a custom scroll. In which I am shifting the contents right
I have created a WebView layout, which is used to access a specific website,
I have created custom cell in which there are n number of image views.
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have created a custom cell for loading into a table. The interface is
I have created a custom view with a XIB file and are loading the
I'm having trouble loading custom HTML into my UIWebView without breaking its goBack method.
I have created Custom User Control which contain TextBox and PasswordBox. it is binding
I have created a custom listview that have one webview per element. My problem

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.