I'm currently using a regular RecyclerView
with GridLayoutManager
with different spanCount
depeding on the viewType
for an Android TV app. All is working decent but I have 2 issues:
RecyclerView
to keep the current focused view in the center of the grid?It seems that the issues listed are fixed by using the VerticalGridView
from LeanBack
library but the LayoutManger
that it uses is internal and doesn't support spanCount
.
Recycler view works fine with android TV.Possible solutions you can include are:
1.add focusable and focusableInTouchode to view.Add focusListner through the code and request focus each time when the view is clicked.
2.To keep Recycler View focused item in the centre you have to override layout manager just like this example.
RecyclerView smoothScroll to position in the center. android
or
use layoutManager.scrollToPositionWithOffset(position,offset) where position-focused view position and offset is the recycler view width/2.