# Tap Detection on Arbitrary Shapes with Compose

DevFeed: [Tap Detection on Arbitrary Shapes with Compose](<https://devfeed.tech/articles/tap-detection-on-arbitrary-shapes-with-compose-25609.md>)

Original publisher: [Read original article](<https://www.romainguy.dev/posts/2025/arbitrary-shape-tap-detection/>)

Author: Romain Guy

Published: 2025-12-07T00:00:00Z

Content type: tutorial

Language: en

Sources: [Posts on Romain Guy](<https://devfeed.tech/sources/posts-on-romain-guy.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Android](<https://devfeed.tech/topics/android.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [compose](<https://devfeed.tech/tags/compose.md>), [developer](<https://devfeed.tech/tags/developer.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [image](<https://devfeed.tech/tags/image.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [parameter](<https://devfeed.tech/tags/parameter.md>), [performance](<https://devfeed.tech/tags/performance.md>), [pixel](<https://devfeed.tech/tags/pixel.md>), [render](<https://devfeed.tech/tags/render.md>)

## AI overview

This tutorial explains how to use Jetpack Compose's PathHitTester API to detect taps and test whether 2D coordinates lie inside arbitrary paths. It covers coordinate transformations, efficient repeated hit testing, updating the tester after path changes, and generating paths from images with the pathway library.

## Source excerpt

Detecting whether a user tapped on an arbitrary shape represented by a Path is an unfortunately difficult task on Android. The Path class does not offer any API to do this, and the workaround I have seen folks use (representing the tap as a small rectangle/circle and computing the intersection with the test shape) is inefficient and sometimes fails. Thankfully, Jetpack Compose a simple way to perform this task. The video below shows how the Compose APIs can be used to detect taps, or generally perform any test requiring to check whether a specific 2D coordinate is contained inside a Path: