Edit Input text with compose library
we have TextInputEditText and EditText for text input in android with compose we have new class that we need to use you can style them with different properties
val state = remember { mutableStateOf(TextFieldValue("Text")) }
Column(modifier = androidx.compose.ui.Modifier.padding(16.dp)) {
TextField(
modifier = androidx.compose.ui.Modifier.fillMaxWidth(),
value = state.value,
onValueChange = {
state.value = it
},
errorColor = Color.Red,
isErrorValue = false,
textStyle = TextStyle(
color = Color.Blue,
fontSize = TextUnit.Companion.Sp(26),
fontFamily = FontFamily.Monospace
),
inactiveColor = Color.Transparent,
activeColor = Color.Transparent,
)
}
fillMaxWidth to fit to screen size inside column
inactive color and active color above are transparent to hide default bottom border setting active and inactive color will change the border color when textfield is active and inactive
setting onValueChange is something important needed for edittext text.
Comments
Post a Comment