KotlinLeaner
10/10/2022, 8:32 PMSpacer
is not working in simple function?KotlinLeaner
10/10/2022, 8:34 PMColumn(
modifier = Modifier
.padding(10.dp)
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceBetween
) {
PairScreenImage()
PairDeviceDescription()
if (viewModel.isBluetoothEnabled) {
PressAndHoldDescription()
WaitingToPair(scanning.value)
UnableToPair(scanning.value)
}
}
WaitingToPair
@Composable
fun WaitingToPair(scanning: Boolean) {
AnimatedVisibility(scanning) {
Spacer(modifier = Modifier.height(10.dp))
Row(
modifier = Modifier
.fillMaxWidth()
.background(OffWhite),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
.... // more item
}
}
}
UnableToPair
@Composable
fun UnableToPair(scanning: Boolean) {
AnimatedVisibility(!scanning) {
Spacer(modifier = Modifier.height(10.dp)
.... // more item
}
}
Space is not working properly between views in function. Any reason behind this?Javier
10/10/2022, 9:08 PMJavier
10/10/2022, 9:09 PMKotlinLeaner
10/10/2022, 9:14 PMRow
and Spacer
inside Column
in WaitingToPair
function.KotlinLeaner
10/10/2022, 9:15 PMColumn
in main function and WaitingToPair
functionKotlinLeaner
10/10/2022, 9:16 PMSpacer
Sean Proctor
10/10/2022, 9:37 PMAnimatedVisibility
. You can do something like:
@Composable
fun ColumnScope.WaitingToPair(...) {
AnimatedVisibility(scanning) {
...
}
}
Sean Proctor
10/10/2022, 9:41 PMAnimatedVisibility
has special versions for ColumnScope
and RowScope
, but you're putting it inside a function without that scopeSean Proctor
10/10/2022, 9:41 PMKotlinLeaner
10/10/2022, 10:08 PMSpacer
? inside ColumnScope.WaitingToPair
or AnimatedVisibility(scanning)
?Doris Liu
10/10/2022, 10:16 PMAnimatedVisibility
uses Layout
to stack all the children. The ColumnScope
and RowScope
extension funs are only helping setting the default enter/exit transition that makes sense in the context of Row/Column. All the children will be placed on top of each other like in a Box
in those variations as well.
With that said, here you could either create another Column in AnimatedVisibility or express the Spacer as a padding
or offset
on the Row
.KotlinLeaner
10/10/2022, 10:29 PMKotlinLeaner
10/10/2022, 10:29 PM