2

So I was checking out this document here https://developer.android.com/jetpack/compose/text#enter-modify-text

I have managed to create a text field (EditText) Using:

@Composable
    fun EmailField() {
        var text by remember { mutableStateOf("") }

        TextField(
            colors = TextFieldDefaults.textFieldColors(
                textColor = Color.White,
                focusedIndicatorColor = Color.White,
                focusedLabelColor = Color.White
            ),
            value = text,
            onValueChange = { text = it },
            label = { Text("Email") }
        )
    }

Now I want to set the drawableStart which we had in XML. So is there any such equivalent or other way to achieve?

I want to create something like this:

JetPack TextField

Any help or lead is appreciated

1 Answer 1

3

You can use the leadingIcon attribute:

TextField(
    value = text,
    onValueChange = { text = it },
    leadingIcon = {
       Icon(Icons.Filled.Email,
        "contentDescription",
        modifier = Modifier.clickable { /* .. */})}
)

enter image description here

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.