Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

426
Views
How to set a threshold for LazyColumn/ViewPager before starting to scroll?

I'm using the experimental viewpager for Jetpack compose which is built upon LazyColumn/Row.

What I'm trying to do is to set some threshold of how much I need to move my finger before it starts to scroll to next page. The default behaviour is that as soon as I move my finger it starts to scroll, but I want to have a larger threshold of how much I need to move the finger before any visual scrolling occur. I've looked at the FlingBehaviour parameter, but I don't see how to use that to accomplish what I want. (Or at least add some more "resistance" to flip between the pages, so it's not so sensitive)

Have you got any ideas?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This threshold is controlled by the flingBehavior argument.

PagerDefaults.flingBehavior(pagerState) provides paging work, currently only animations are configurable, so you can't just provide your own instead behavior instead. But you can wrap it like this:

private class FlingBehaviourMultiplier(
    private val multiplier: Float,
    private val baseFlingBehavior: FlingBehavior
) : FlingBehavior {
    override suspend fun ScrollScope.performFling(initialVelocity: Float): Float {
        return with(baseFlingBehavior) {
            performFling(initialVelocity * multiplier)
        }
    }
}

@Composable
fun rememberFlingBehaviorMultiplier(
    multiplier: Float,
    baseFlingBehavior: FlingBehavior
): FlingBehavior = remember(multiplier, baseFlingBehavior) {
    FlingBehaviourMultiplier(multiplier, baseFlingBehavior)
}

Usage:

val pagerState = rememberPagerState()
HorizontalPager(
    count = 10,
    state = pagerState,
    flingBehavior = rememberFlingBehaviorMultiplier(
        multiplier = 0.5f,
        baseFlingBehavior = PagerDefaults.flingBehavior(pagerState)
    ),
    modifier = Modifier
) { page ->
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!