Expand clickable area of an ImageView by using padding?

后端 未结 4 842
小蘑菇
小蘑菇 2021-02-04 02:19

I have an ImageView, and I want it to be clickable. The image itself is only 32x32 pixels, but I want the clickable region to be larger so it\'s easier to hit. I was hoping I co

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 02:41

    Suggestions (never tried it myself):

    1. Create ImageView as large as you want than put image into it without scaling

      ImageView.setScaleType(ImageView.ScaleType.CENTER).
      
    2. Brute force approach: create new larger png that has original image centered and the rest of it is transparent.

提交回复
热议问题