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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:49:41+00:00 2026-05-13T23:49:41+00:00

Greets, Does anyone how I go about detecting when a user presses on a

  • 0

Greets,

Does anyone how I go about detecting when a user presses on a bitmap which is inside a canvas?

Thanks

  • 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-05-13T23:49:41+00:00Added an answer on May 13, 2026 at 11:49 pm

    You should work with something like so:

    public boolean onTouchEvent(MotionEvent event){
        int action = event.getAction();
        int x = event.getX()  // or getRawX();
        int y = event.getY();
    
        switch(action){
        case MotionEvent.ACTION_DOWN:
            if (x >= xOfYourBitmap && x < (xOfYourBitmap + yourBitmap.getWidth())
                    && y >= yOfYourBitmap && y < (yOfYourBitmap + yourBitmap.getHeight())) {
                //tada, if this is true, you've started your click inside your bitmap
            }
            break;
        }
    }
    

    That’s a start, but you need to handle case MotionEvent.ACTION_MOVE and case MotionEvent.ACTION_UP to make sure you properly deal with the user input. The onTouchEvent method gets called every time the user: puts a finger down, moves a finger already on the screen or lifts a finger. Each time the event carries the X and Y coordinates of where the finger is. For example if you want to check for someone tapping inside your bitmap, you should do something like set a boolean that the touch started inside the bitmap on ACTION_DOWN, and then check on ACTION_UP that you’re still inside the bitmap.

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

Sidebar

Related Questions

Greets to all! I want to describe each kind of product by a class:
I have a Windows service that is written in C++ using VS2008. I now
i've created a login screen via a modalviewcontroller. But certainly i have a problem
I would like gnuplot to use the same font in the postscript-terminal as it
I am using this Math for a bg color animation on hover: var col
I have a simple web service as below /** * Test web service */
I have to write a PHP script that works as a client against another
Sometimes I tend using autocomplete from eclipse (3.5) for anonymous inner types. For some
Currently we use a session per Operation (anti-) Pattern with Hibernate/Spring for our Swing
i want to check via php if a page is a cms_page in Magento.

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.