I am working on an android wear app, I already added rotary input to recyclerview using rcView.requestFocus(),but it doesn't work with NestedScrollview so I want to know how to add the rotary input listener to NestedScrollview.
Here is what I have done so far
binding.mainScroll.setOnGenericMotionListener { v, ev ->
if (ev.action == MotionEvent.ACTION_SCROLL &&
ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)
) {
val delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL) *
ViewConfigurationCompat.getScaledVerticalScrollFactor(
ViewConfiguration.get(applicationContext), applicationContext
)
v.scrollBy(0, delta.roundToInt())
true
} else {
false
}
}