Colton Idle
09/16/2021, 11:11 PMColton Idle
09/16/2021, 11:12 PMval myPics = listOf<String>(
"<https://images.unsplash.com/photo-1631804924848-1f01a975972c?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=934&q=80>",
"<https://images.unsplash.com/photo-1606787366850-de6330128bfc?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2000&q=80>"
)
val pagerState = rememberPagerState(pageCount = myPics.size)
if (myPics.isNotEmpty()) {
HorizontalPager(
state = pagerState, modifier = Modifier
.fillMaxWidth()
.weight(.75F)
) { page ->
Image(
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
painter = rememberImagePainter(
data = myPics[pagerState.currentPage],
builder = {
crossfade(true)
}
),
contentDescription = null,
)
}
}
Albert Chang
09/16/2021, 11:57 PMmyPics[pagerState.currentPage]
to myPics[page]
.Colton Idle
09/16/2021, 11:58 PM