Android 检测shapeDrawable内是否发生触摸事件

Android 检测shapeDrawable内是否发生触摸事件,android,android-layout,ontouchlistener,shapedrawable,Android,Android Layout,Ontouchlistener,Shapedrawable,我在自定义android视图中通过画布绘制了许多ShapeDrawable。我有一个onTouchEvent方法,它工作得很好。一切正常。现在,我希望能够检测触摸事件是否与某个形状的可移动对象相交(即发生在内部)。有办法吗?我得到了答案: sd.getBounds().contains(x, y)

我在自定义android视图中通过画布绘制了许多ShapeDrawable。我有一个onTouchEvent方法,它工作得很好。一切正常。现在,我希望能够检测触摸事件是否与某个形状的可移动对象相交(即发生在内部)。有办法吗?

我得到了答案:

  sd.getBounds().contains(x, y)