Android image with clickable areas

后端 未结 4 1316
自闭症患者
自闭症患者 2021-01-03 13:52

I need an advice how to achieve the following functionality under Android:

  • I need an image that represents something like a graph (from discrete math), with ve
4条回答
  •  孤城傲影
    2021-01-03 14:56

    I think you might be best off with a SurfaceView:

    http://developer.android.com/reference/android/view/SurfaceView.html

    And handling the onTouchEvent() as a whole for the surface, and mapping that to underlying entities in the image. If you're calculating the drawing the graph as you go should be easy to also create a map of tapable areas and grabbing the X and Y of the touch event to figure out if it corresponds to an element in the image.

    If you literally have an image, as an already processed PNG for example, you would need some way to also carry in the touch event areas. Depends where that image comes in from.

提交回复
热议问题