Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there a way to get the value of the y position while the screen is scrolling?

I have a situation like this:

LazyColumn() {
    item {
      box()
      box()
      box()
      ScrollableTabRow(){}
    }
    itemsIndexed {...}

I need to know when the ScrollableTabRow moves past a certain position on y axis (for example lets say 100.dp )

I tried working with .scrollable() (something like scrollable)

and with scroll gesture filter (something like gesture

and with dragGestureFilter but i cannot get it to work, am i doing something wrong, or is it just not possible?

Basically what i need to do is for the scrollable tab row to act as sticky header after it touches top of the screen.

What i wanted to do is, after scrollable row touches the top of the screen, create some sort of mockup for it at the top of the screen, but maybe there is some easier way?

App is written strictly in compose, so i dont have access to any of the libraries that provide such implementation


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
226 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use stickyHeader.

LazyColumn {
  item { ... }
  stickyHeader {
    ScrollableTabRow(...) { ... }
  }
  item { ... }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...