Created
April 11, 2023 10:47
-
-
Save saqib-github-commits/2daa7d0f00af9f6978640ee78d2c6f26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun HorizontalPagerWithIndicatorsScreen() { | |
val images = listOf( | |
R.drawable.logo_android, | |
R.drawable.logo_kotlin, | |
R.drawable.logo_apple, | |
R.drawable.logo_fb, | |
R.drawable.logo_google, | |
) | |
Column { | |
HorizontalPagerWithIndicators(images) | |
} | |
} | |
@OptIn(ExperimentalFoundationApi::class) | |
@Composable | |
fun HorizontalPagerWithIndicators(images: List<Int>) { | |
val pagerState = rememberPagerState() | |
Box(modifier = Modifier | |
.fillMaxWidth() | |
.height(300.dp) | |
) { | |
HorizontalPager(pageCount = 5, state = pagerState) { | |
Image( | |
painter = painterResource(id = images[it]), | |
contentScale = ContentScale.Crop, | |
contentDescription = "" ) | |
} | |
HorizontalPagerIndicator( | |
modifier = Modifier | |
.align(Alignment.BottomCenter) | |
.padding(bottom = 10.dp), | |
pageCount = 5, | |
pagerState = pagerState, | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment