Thinking of a way to deal cards at the bottom of the screen, I know I need to calculate to offset so that the cards will be set next to one another. is there a way to have a trigger to when I deal a card, that the space is evaluated (remember) and tiimed the number of cards so that a suitable offset will be made? I took some pictures of what I'm trying to achieve (mockups) 1 card 2 cards and even more mockups 3 cards 4 cards
@Composable
fun ScreenContent() {
val width = (Resources.getSystem().displayMetrics.widthPixels / Resources.getSystem().displayMetrics.density).roundToInt()
val height = (Resources.getSystem().displayMetrics.heightPixels / Resources.getSystem().displayMetrics.density).roundToInt()
val offset = (width / 6)
Column(
modifier = Modifier
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
CustomColumnSurface(1f) {}
CustomColumnSurface(3f, color = Color.White, padding = 16.dp) {
Row(
modifier = Modifier
.fillMaxWidth(),
) {
CustomRowSurface(1f) {}
CustomRowSurface(1f) {}
CustomRowSurface(1f) {}
}
}
CustomColumnSurface(1f) {
val painter = painterResource(id = R.drawable.clubs_2)
val description = "clubs 2"
val last = 1
var space = (width/(last+1))-((135*last)/2)
println(space)
for (i in 1..last) {
Box(modifier = Modifier
//.fillMaxHeight()
.offset(space.dp)
) {
ImageCard(
painter = painter,
contentDescription = description,
)
}
//space += (last*(135/2))
}
}
}
}
