3
  • I want to make 4 different border clicks of an imageview.
  • also, border should be strechable with imageview.
  • How can i differentiate four corner's click with placing drawable also ?

custom_img_with_4_corner_click

Bull
  • 11,771
  • 9
  • 42
  • 53
Jack 1990
  • 49
  • 3

1 Answers1

2

You are going to need to make a custom view and Override onDraw().

First, use canvas.drawBitmap() to get the image to show up.

Second, use canvas.drawRect() 4 times to get each of your corner buttons. (You'll have to get the left, top, right, bottom from your bitmap to get the coordinates for your 4 rects)

Third, Override onTouch() to intercept the XY touch coordinates

Fourth, use the intercepted touch coordinates in myRect.contains(x,y) to find out if your rect was touched. Then you can complete any action you need when the rect it touched

Hope this helps.

Kent Andersen
  • 2,151
  • 3
  • 21
  • 29