Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accompanist Pager `offscreenLimit` removed. How to disable preloading of nearby pages?

Since version v0.19.0; offscreenLimit parameter has been removed. How to disable preloading using some other technique?

    @Composable
    fun MyComposable(){
        val pagerState = rememberPagerState()
        HorizontalPager(
            state = pagerState,
            modifier = Modifier.fillMaxSize(),
            count = itemList.size,
        ) { i ->

            MyPage(i)
        }
    }
like image 362
Shreyash.K Avatar asked Dec 12 '25 22:12

Shreyash.K


1 Answers

What about something like this?

HorizontalPager(...) { i ->
    if ((pagerState.currentPage - i).absoluteValue > 1) {
        EmptyPage()
    } else {
        MyPage(i)
    }
}
like image 78
Jan Bína Avatar answered Dec 14 '25 14:12

Jan Bína



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!