KotlinLeaner
02/15/2023, 12:50 PMweight
modifier in better way in Column
.KotlinLeaner
02/15/2023, 12:50 PMHorizontalPager(
count = 5,
state = pagerState,
) { currentPage ->
val (descriptionResId, imageResId, stepId) = list[currentPage]
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.height(height = 524.dp)
) {
Image(
modifier = Modifier.weight(8f),
painter = painterResource(imageResId),
contentDescription = null,
)
Text(
modifier = Modifier
.weight(2f)
.padding(top = 20.dp),
text = stringResource(stepId),
)
Text(
modifier = Modifier
.weight(3f)
.padding(top = 20.dp),
text = stringResource(descriptionResId),
textAlign = TextAlign.Center,
)
HorizontalPagerIndicator(
modifier = Modifier.weight(4f),
pagerState = pagerState,
)
}
}
orangy
KotlinLeaner
02/15/2023, 1:04 PMorangy
KotlinLeaner
02/15/2023, 1:09 PMKotlinLeaner
02/15/2023, 1:10 PMorangy
Modifier.height(height = 524.dp)
, why don’t you pre-calculate heights of all children and specify them explicitly?KotlinLeaner
02/15/2023, 2:00 PMorangy
weight
on all items except the pager, and size pager explicitly. You can set heightIn
to set minimum height, etc. Depending on what do you want to achieveKotlinLeaner
02/15/2023, 3:12 PMKotlinLeaner
02/15/2023, 3:12 PM