Context,
I want to animate the support text as it appears and disappears.
Abhimanyu
10/22/2023, 4:15 AM
Sample Code for reference,
Copy code
@Composable
fun OutlinedTextFieldSupportTextSample() {
var text by remember {
mutableStateOf("")
}
Column(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.background(Color.LightGray)
)
OutlinedTextField(
value = text,
onValueChange = {
text = it
},
supportingText = {
AnimatedVisibility (text.isBlank()) {
Text("Text cannot be blank")
}
},
)
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.background(Color.LightGray)
)
}
}
Abhimanyu
10/22/2023, 4:17 AM
Passing
null
to the
supportText
like this removes the space, but it does not animate.
Copy code
supportingText = if (text.isBlank()) {
{
AnimatedVisibility(text.isBlank()) {
Text("Text cannot be blank")
}
}
} else {
null
},
z
Zach Klippenstein (he/him) [MOD]
10/23/2023, 3:21 AM
The presence of that function is probably used to reserve space, not the contents. So what you’re doing probably isn’t supported. Feel free to file a feature request