Home > Mobile >  Unresolved reference: pagerTabIndicatorOffset
Unresolved reference: pagerTabIndicatorOffset

Time:12-10

I'm pretty new to jetpack and am following enter image description here

CodePudding user response:

Starting of Jetpack Compose 1.4.0-alpha03 there is a native HorizontalPager. androidx.compose.foundation.pager.HorizontalPager which you don't have to use pagerTabIndicatorOffset.

Sample

@Composable
private fun HomeContent() {

    val pagerState: PagerState = rememberPagerState(initialPage = 0)
    val coroutineScope = rememberCoroutineScope()

    TabRow(
     
        selectedTabIndex = pagerState.currentPage
    ) {
        // Add tabs for all of our pages
        tabList.forEachIndexed { index, title ->
            Tab(
                text = { Text(title) },
                selected = pagerState.currentPage == index,
                onClick = {
                    coroutineScope.launch {
                        pagerState.animateScrollToPage(index)
                    }
                },
            )
        }
    }

    HorizontalPager(
        state = pagerState,
        pageCount = tabList.size,
        beyondBoundsPageCount = 3
    ) { page: Int ->

        when (page) {
           
        }
    }
}
  • Related