Richard Onslow Roper
Richard Onslow Roper

Reputation: 6863

Retrieving current item in lazyrow

I wish to create a LazyRow where one of the items will be higher in elevation than the others, as in essentially focused. Now, as I scroll, I wish to highlight the next item with elevation. What I want is something like, the first visible item in the Row, currently, shall be elevated above others. Any ideas?

Upvotes: 1

Views: 1753

Answers (1)

Nikunj
Nikunj

Reputation: 4157

To get first visible index from list, You can use the LazyListState.firstVisibleItemIndex property.

Official guide regarding the Lists: Reacting to scroll position

For simple use-cases, apps commonly only need to know information about the first visible item. For this LazyListState provides the firstVisibleItemIndex and firstVisibleItemScrollOffset properties.

Upvotes: 2

Related Questions