RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 406 forks source link

OnTouchListener Not Working #102

Closed eygraber closed 6 years ago

eygraber commented 6 years ago

It's not possible to set a touch listener on CameraView because the focus layout steals touches.

My use case is to take a picture when the CameraView is tapped. I've gotten around it by putting a transparent overlay on top, and setting the touch listener on that, but I'd rather not have to.

dmitry-zaitsev commented 6 years ago

I can't reproduce this issue in our sample app. Also, not sure which focus layout are you talking about?

I am closing this issue until further information is provided.

danielgindi commented 5 years ago

In FocusView.kt:

@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
  tapDetector.onTouchEvent(event)
  return true // <------ This line, means "the event was consumed". Thus the parent view does not get any touches
}