Closed fankloano closed 6 months ago
Hi @fankloano
You can use setSelectedPosition
to achieve this. DpadRecyclerView
will only dispatch focus after you invoke that if it already has focus.
Oooh, using recyclerview.post solved the problem and setSelectedPosition works as you said: binding.rvFullepg.post { binding.rvFullepg.setSelectedPosition(currentProgramPosition) }
@fankloano I'm glad you managed to get it working :)
Another question I have come across in the meantime: Is it possible to scroll a nested recyclerview to a specific point (without giving it the focus)? I have attached a picture to clarify what I mean. The respective date is displayed on the left in the yellow recyclerview. If a date receives the focus, the corresponding EPG data of this day for the channel is displayed on the right. If today's date is selected, the recyclerview on the right should display the currently running program in the middle (i.e. theoretically scroll to it), if the user then clicks to the right to go to the epg-data-recyclerview, the current program receives the focus (as far as I know, this can be implemented with setSelection(currentProgramPosition)). If the focused date is not today's date, the first visible item should simply be the first program for the date, i.e. the normal behavior. I played around with setSelection or scrollToPosition because I thought that was one of the things it was made for, but I couldn't achieve my desired scenario. Is there any way to do this?