Jack
Jack

Reputation: 142

How add TextField on Row?

I cannot add textfield on row. I already tried to use row, flexrow, flowrow, stack, wrap and container. On column it works.

java.lang.IllegalArgumentException: minWidth 2147483647.ipx should be finite
at androidx.ui.core.Constraints.<init>(Constraints.kt:48)   
at androidx.ui.core.Constraints$Companion.tightConstraintsForWidth(Constraints.kt:72) 
at...

I want to output like this;

Username: (TEXTFIELD)

Upvotes: 0

Views: 875

Answers (1)

Anas Mehar
Anas Mehar

Reputation: 2835

Try below code

MaterialTheme {
                val state = +state { " " }
                Padding(left = 16.dp, right = 16.dp) {
                    FlexRow(
                        crossAxisAlignment = CrossAxisAlignment.Center
                    ) {
                        inflexible {
                            Container() {
                                Text{
                                    Span(
                                        text = "Username: ",
                                        style = TextStyle(
                                            color = Color(0xFFFF0000),
                                            fontSize = 18.sp,
                                            fontWeight = FontWeight.W200,
                                            fontStyle = FontStyle.Normal
                                        )
                                    )
                                }
                            }
                        }
                        expanded(1f) {
                            TextField(value = state.value, onValueChange = { state.value = it })
                        }
                    }
                }
            }

Output:

enter image description here

Upvotes: 5

Related Questions