Skip to content

Instantly share code, notes, and snippets.

@aqua30
Last active June 18, 2023 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aqua30/fcce5300e208cdab48219b4b1f0fe5b9 to your computer and use it in GitHub Desktop.
Save aqua30/fcce5300e208cdab48219b4b1f0fe5b9 to your computer and use it in GitHub Desktop.
val userImages = listOf(
R.drawable.img_user_1,
R.drawable.img_user_2,
R.drawable.img_user_3,
R.drawable.img_user_4,
R.drawable.img_user_5,
)
...
Box(modifier = Modifier.fillMaxSize()) {
userImages.forEachIndexed { index, drawable ->
val offsetX = (screenWidth - 25.dp) / 2 // horizontal offset
val offsetY = ((screenHeight - 25.dp) / 2) + (index * 50).dp // vertical offset including item index
val modifier = Modifier
.size(50.dp)
.absoluteOffset(
x = offsetX,
y = offsetY,
)
UserImage(modifier = modifier, image = drawable)
}
FloatingActionButton(
modifier = Modifier
.align(Alignment.BottomEnd)
.padding(16.dp),
onClick = { isHorizontal = isHorizontal.not() }
) {
Text("Click")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment