Search code examples
androidimageuiimageviewpreviewevent-listener

Android - How to set onClick listener for a portion of an ImageButton


I have an application with an ImageButton that when clicked triggers a method. Now my problem is that I want a portion of that same ImageButton that when clicked calls a different method. I would like to set the bottom right corner to call a different method than the one being called when clicking the ImageButton.

The idea is that clicking the image button triggers a save to a database, but the clicking on the corner should display a preview of the image.

Any help on how this can be achieved will be highly appreciated.

Thanks


Solution

  • Check this out Android ImageLayout... you could use an ImageLayout as an imagebutton. On the specified points/corners (rectHint), you could place a different clicklistener, which executes a different method.

    I didnt try, but it "should" solve your problem.