I have turned on my voice assistant in on in my Note 5 and trying to move forward (up to down) but it is going out of Recyclerview when it reaches to end of the screen. As there are many more items in the list so it should auto-scroll up.
I have observed this issue in Samsung Note 5 and Samsung Note 9 but it is working fine in Samsung 9 and Samsung 9+.
I have maintained focusable true in every item of RecyclerView. I have used a solution but i don't think it is the best one can anyone suggest me what would be the best approach.
My solution: I am manually scrolling the list by detecting the moment.
RecyclerView
<RecyclerView>.setAccessibilityDelegateCompat(RVAccessibilityDelegate(<RecyclerView>, <No of item you want to scroll>))
RVAccessibilityDelegate
RecyclerViewAccessibilityDelegate(recyclerView){
private var previousItemPosition = 0
override fun onRequestSendAccessibilityEvent(host: ViewGroup, child: View, event: AccessibilityEvent): Boolean {
if (event.eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
if (host is RecyclerView) {
var childPosition = host.getChildAdapterPosition(child)
if (childPosition == 0 && previousItemPosition == 0) {
host.smoothScrollToPosition(1)
} else if (previousItemPosition < childPosition) {
host.smoothScrollToPosition(childPosition + scrollItem)
previousItemPosition = childPosition
} else if (previousItemPosition > childPosition) {
var scrollUpto = childPosition - scrollItem
if (scrollUpto < 0) {
scrollUpto = 0
}
if (childPosition == 0) {
host.smoothScrollToPosition(childPosition)
} else {
host.smoothScrollToPosition(scrollUpto)
}
previousItemPosition = childPosition
}
}
return true
}
return super.onRequestSendAccessibilityEvent(host, child, event)
}
}```