我正在开发一个 android wear 应用程序,我已经使用 rcView.requestFocus() 将旋转输入添加到 recyclerview,但它不适用于 NestedScrollview,所以我想知道如何将旋转输入侦听器添加到 NestedScrollview。
这是我到目前为止所做的
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
}
}