android / android/snippets

The following code may encounter issues when using AnimatedVisibility, as the animation is very uneven

Open
#224 3 comments 0 reactions 1 assignee Assigned to @riggaroo View on GitHub
Dominant language
Kotlin
Stars
1.1k
Forks
419
Avg merge
3d 18h
Merged PRs (30d)
28

Description

```

@Preview
@Composable
fun AnimatedVisibilityCookbook() {
var visible1 by remember {
mutableStateOf(true)
}

var visible2 by remember {
mutableStateOf(true)
}
Row(
modifier = Modifier.padding(top = 20.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
Button(
modifier = Modifier,
onClick = {
visible1 = !visible1
},
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
Text(
text = "text",
color = Color.Black,
textAlign = TextAlign.Center
)
}
AnimatedVisibility(
modifier = Modifier.weight(1f),
visible = visible1
) {
Button(
modifier = Modifier,
onClick = { },
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
Text(
text = "text1",
color = Color.Black,
textAlign = TextAlign.Center
)
}
}
AnimatedVisibility(
modifier = Modifier.weight(1f),
visible = visible2
) {
Button(
modifier = Modifier,
onClick = { },
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
Text(
text = "text2",
color = Color.Black,
textAlign = TextAlign.Center
)
}
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.