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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:53:12+00:00 2026-06-12T17:53:12+00:00

The button is drawn on the canvas via onDraw . In the following method

  • 0

The button is drawn on the canvas via onDraw. In the following method I am getting the location of the drawn button and detecting a touch inside it. Once it is sensed snapShot(); is called. I’ve replaced the content of snapShot(); with System.out.println("snapShot(); is called");. Every touch I constantly get four lines printed out. I don’t understand how this method is calling snapShot() for times in a row?

public boolean onTouch(View view, MotionEvent me) {
    Resources res = getResources();
    Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.camera);
    DisplayMetrics metrics = getResources().getDisplayMetrics();
        int w = metrics.widthPixels;
        int h = metrics.heightPixels;
        int heightOffset = - bitmap.getHeight() + h;
        int widthOffset = w - bitmap.getWidth();
    //See if the motion event is on a Marker
     if((me.getRawX() >= widthOffset && me.getRawX() < (widthOffset + bitmap.getWidth()) 
                && me.getRawY() >= heightOffset && me.getRawY() < (heightOffset + bitmap.getHeight()))) 
        {
            snapShot();
            return true; 

    }

    return super.onTouchEvent(me);
};
  • 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-12T17:53:14+00:00Added an answer on June 12, 2026 at 5:53 pm

    Because onTouch is called when your finger goes down, when it moves and when it’s lifted. You need to examine MotionEvent to determine what finger is doing what. It can also be very difficult to touch without causing a move event – see touch slop.

    http://www.mybringback.com/tutorial-series/3279/android-the-basics-32-androids-ontouchlistener-and-motionevent/

    Android ACTION_MOVE Threshold

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

Sidebar

Related Questions

I have the following code which takes a touch on one button and draws
Consider a Button composed of many graphical elements (and Path ) drawn on Canvas
I've got a problem with canvas context drawImage() method if an image is drawn
I've got a canvas drawn (I have to keep the canvas, it's doing other
I am trying to change the color of line drawn on canvas dynamically... ctx.moveTo(0,
I have drawn a bar chart without xml.I have to add a button below
The onKeyDown method does not function. When i press the button the bitmap s
In my app i am able to draw something on canvas within on touch
I want to zoom in the canvas board partially as the letter tray button
My simple application has google map with overlay. And a onDraw() method to place

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.