How to focus on a specific item in a TvLazyRow?
Consider the following code :
val tvListState = rememberTvLazyListState()
val coScope = rememberCoroutineScope()
Column{
TvLazyRow(
horizontalArrangement = Arrangement.spacedBy(15.dp),
state = tvListState,
modifier = modifier
.padding(end = 5.dp)
, pivotOffsets = PivotOffsets(0f)) { *items* }
TvLazyRow(
horizontalArrangement = Arrangement.spacedBy(15.dp),
state = tvListState,
modifier = modifier
.padding(end = 5.dp)
, pivotOffsets = PivotOffsets(0f)) { *items* }
TvLazyRow(
horizontalArrangement = Arrangement.spacedBy(15.dp),
state = tvListState,
modifier = modifier
.padding(end = 5.dp)
, pivotOffsets = PivotOffsets(0f)) { *items* }
}
What I want to do is to focus on a specific item in one of the lazy rows when we enter the row, and have it tied to a flag, could be something like preFocusOnItem
. In my current implementation I am having to call focus on this item using itemsRequester[preFocusOnItem].requestfocus()
inside LaunchedEffect
, where the array is used to assign a focus requester to each of the items. The problem with this approach is the focus first comes to the item that scrolling naturally will bring focus to, and after a split second the focus jumps to the item I want to focus on.
How do I directly call focus on the preFocusOnItem
item when entering one of the TvLazyRows
??
Source: View source