Anybody tried LazyColumn or LazyGrid on Android TV...
# compose
a
Anybody tried LazyColumn or LazyGrid on Android TV? For me, they don't scroll down. See the attached video, first example is with
LazyColumn
, second one is just
Column
with
verticalScroll
modifier. Edit: Looks like this is related to d-pad navigation because when I swipe using
scrcpy
, all the rows are there.
s
Do you think it’s a bug with your code or bug with compose in general? What did any official forums say about it?
a
I think it's a bug with Compose given that swiping works fine and because there's been issues with d-pad navigation in compose in the past but I'm open to suggestions. The roadmap says d-pad navigation is in-focus so I'm guessing this would be the right time to bring up any bugs with it.
s
Bet they’d appreciate your video and a report of what is happening! 🤔
a
In the past, I've posted here and verified a behaviour before submitting an issue.
j
There is a known issue on lazy lists not scrolling at the moment
Already on the issue tracker
🙌 2
f
@Jon Boekenoogen is it for Android TV only or for Phones too?
j
Lazy list scrolling with dpad in general (tv, chrome os, phones)
👍 2
t
We’ve solved this by using
rememberLazyListState
and
scrollBy(px)
to center the items upon focus (
scrollToIndex()
also should work). We’re on version 1.0.5. We experienced the same issue as you, and it seems it’s related to the items not being visible.
❤️ 1
a
@Tarjeison Did that completely solve the problem? I tried
scrollBy
and
scrollToIndex
, I think
scrollBy
worked but
animateScrollBy
didn’t. Would it be possible for you to share that part of the code by any chance?
t
I think this is an issue which occurred in version 1.1.0 and might be the same same as this issue: https://issuetracker.google.com/issues/212982472 I’ve also added a gist in the issue. My team decided to wait for a built in focus navigation support for compose before implementing it on AndroidTV. https://issuetracker.google.com/issues/184670295
a
Ah, that makes a lot of sense because I only tried it with 1.1.0. I see that Ralston Da Silva is actively working on it in this CL: https://android-review.googlesource.com/c/platform/frameworks/support/+/1967229. Looks like a while before it’s all done though. I tried it locally a few patch sets ago 🙂
👀 1