Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Attachment actions
Unintended behavior
View staffing
Description
Jetpack Compose version: 1.2.0
Jetpack Compose component(s) used:
foundation
(LazyList
,scrollable
,BringIntoViewResponder
)Android Studio Build: Chipmunk
Kotlin version: 1.7.0
We've been trying to use LazyLayouts for Android TV for a while, but struggle with focus navigation. Our goals is to have a
LazyColumn
containing a list ofLazyRow
s showing items. It's important for us that the focused item is centered in the screen. See attached video for a demonstration of how it works in the old implementation (usingRecyclerView
s).For a while we've tried to do it manually: Whenever a new item was focused, we would scroll horizontally and vertically. One issue by doing this was however that b/212982472 .
BringIntoViewResponder
was cancelling the scrolls - seeSo we've instead tried to use
BringIntoViewResponder
as it seems like the way to do it, but it doesn't behave as expected. Whenever we receive a call tobringChildIntoView
the coordinates are outdated as anotherBringIntoViewResponder
already started scrolling a bit if the view wasn't fully visible - most likely by the the defaultBringIntoViewResponder
inscrollable
.We've tried to make a simple example that shows our issue. It's really a simplyfied version of it, but it still happens in this case. Here we're only using a
LazyRow
, but it happens for columns as well. If you uncomment the two log-statments (and print them to log) it's clear that when you navigate to item with index 4 (that's not fully visible) we're basing out calculations on an outdated localRect.