Compose Material 3
I am trying to create a OutlinedTextField that has rounded corners. However, the white background can still be seen squared as the background.
How can I remove this white background
This is my composable:
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EmailEntry(
modifier: Modifier = Modifier,
isValidEmail: Boolean,
onEmailChange: (String) -> Unit
) {
var emailValue by remember {
mutableStateOf("")
}
OutlinedTextField(
modifier = modifier.background(
shape = RoundedCornerShape(10.dp),
color = MaterialTheme.colorScheme.backgroundInputEntry
),
singleLine = true,
value = emailValue,
onValueChange = { newInput ->
emailValue = newInput
onEmailChange(newInput)
},
placeholder = {
Text(text = "Email address", color = MaterialTheme.colorScheme.placeholderEntry)
},
trailingIcon = {
if (isValidEmail) {
Image(
painter = painterResource(id = R.drawable.tick),
contentDescription = "Valid email tick"
)
}
},
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = MaterialTheme.colorScheme.focusedInputEntryBorder,
unfocusedBorderColor = Color.Transparent),
shape = RoundedCornerShape(10.dp)
)
}
@Composable @Preview(showBackground = true)
fun PreviewEmailEntryValidEmail() {
Surface {
EmailEntry(
isValidEmail = true,
onEmailChange = { email ->
Log.d("EMAIL_ENTRY", email)
}
)
}
}