1

How to make the bitmap image clickable on canvas in android like a button on click listener?

1 Answers1

1

You cannot set click listeners directly on a Canvas. If your bitmap is being set to an ImageView, you can just set a click listener on it as normal:

imageView.setOnClickListener(view -> {
    //do something
})

Otherwise, you can create a custom View and use your Canvas in its onDraw() method. You can then use the onTouch() method to capture click events.

Orbit
  • 2,985
  • 9
  • 49
  • 106