Skip to content
Advertisement

In Android Jetpack compose how to achieve GestureDetector.SimpleOnGestureListener…..?

I want to observe onFling Function to detect Velocityx and Velocity Means Swiping force/Velocity. In android we attach this to the android view.But donot find a way how to call this in Jetpack compose or alternative function for this in jetpack compose…?

Advertisement

Answer

Please take the Animation-in-Compose codelab to understand better, but for now, here’s how you can achieve something similar

JavaScript

I would not recommend trying to comprehend this code just from here, you should probably refer to the documentation at hand, while taking the codelab as well. This implements a swipe-to-dismiss functionality on a simple list item in a compose-sample app, the code to which you will find linked to in the start of the codelab. Here are all the sample apps published for compose, for your reference.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement