Android: How to handle right to left swipe gestures

前端 未结 22 1520
日久生厌
日久生厌 2020-11-21 06:18

I want my app to recognize when a user swipes from right to left on the phone screen.

How to do this?

22条回答
  •  轮回少年
    2020-11-21 07:17

    the usage of Edward Brey's answer in Kotlin

     view.setOnTouchListener(object: OnSwipeTouchListener(this) {
          override fun onSwipeLeft() {
            super.onSwipeLeft()
          }
          override fun onSwipeRight() {
            super.onSwipeRight()
          }
        }
     )
    

提交回复
热议问题