Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetpack Compose SingleLine Input Text

Is it possible to set singleLine or maxLines on TextField?

I've checked a source and it's missing. Any ideas / workarounds?

like image 715
Chesteer89 Avatar asked Jul 14 '20 12:07

Chesteer89


2 Answers

You can use the parameter maxLines or singleLine:

TextField(
    //..
    maxLines = 1)

or

TextField(
    //..
    singleLine = true)
like image 101
Gabriele Mariotti Avatar answered Nov 07 '22 22:11

Gabriele Mariotti


Since Compose 1.0.0-alpha08, you can use singleLine parameter to make the text field a single horizontally scrollable line:

TextField(
    value = text,
    onValueChange = { },
    singleLine = true
)
like image 39
Saurabh Thorat Avatar answered Nov 07 '22 22:11

Saurabh Thorat