Material Design implementation in Jetpack compose of a TextField
Questions tagged [android-compose-textfield]
242 questions
9
votes
2 answers
Do Assistive Text, Error Message, Character Counter exist for Jetpack Compose TextField?
In material design TextField page TextField has properties such as
Assistive elements provide additional detail about text entered into
text fields.
Helper text Helper text conveys additional guidance about the input field, such as how it will be…

Thracian
- 43,021
- 16
- 133
- 222
8
votes
3 answers
Row with two Text in Constraint fashion in Jetpack Compose
I want to include two Text in a Row where the first Text's width is upto the start of 2nd Text, like this
I am trying Modifier weight but the result achieved is not the same.
Is there a way to do it by using Row itself and not…

Ali_Waris
- 1,944
- 2
- 28
- 46
8
votes
2 answers
How to create a text field input with mask in jetpack compose?
I need a text field in jetpack compose that works with a mask like this: NNNNN-NNN where N is an integer from 0 to 9. I need my composable function to have this mask in the OutlinedTextField :
@Composable
private fun EditTextField(
labelText:…

Pierre Vieira
- 2,252
- 4
- 21
- 41
8
votes
4 answers
Jetpack Compose TextField text colour in dark mode
I've been experimenting with Jetpack compose and I've noticed that although the text colour updates correctly for Text when you switch to dark mode, the text colour for TextField or OutlinedTextField remains stubbornly black. The labels and hint are…

Barry Irvine
- 13,858
- 3
- 25
- 36
7
votes
1 answer
Jetpack Compose: Textfield doesn't lose focus on click outside of it
I am trying to implement a searchbar in my Compose app. I have a textfield, which I want to lose focus of and hide the keyboard, when I click outside of the textfield. However, I can't figure out how to do it. I did try to do it this way, which I…

CJR
- 3,174
- 6
- 34
- 78
7
votes
5 answers
How to apply a mask date (mm/dd/yyyy) in TextField with Jetpack Compose?
I have a TextField in which there cannot be more than 10 characters, and the user is required to enter date in the format "mm/dd/yyyy". Whenever user types first 2 characters I append "/", when the user types next 2 characters I append "/" again.
I…

Sparsh Dutta
- 2,450
- 4
- 27
- 54
6
votes
2 answers
How to restrict Keyboard Enter key not to allow input in the next line (TextField in Android Jetpack Compose)
In Android emulator, entering input using Computer Keyboard, but the "Enter" key on my keyboard should take the input and do the action. Instead, the input is allowing me in the next line, and keep on continuing to the next line (as a new line…

Kiran
- 63
- 4
6
votes
1 answer
Unexpected Text colour alpha in Jetpack Compose Material Theme
I discovered today that MaterialTheme applies an alpha to Text's colour. As you can see from the example attached, when I change the background colour, the text's colour appears to be different because it has a transparency value. I can force set a…

Fried Rice
- 3,295
- 3
- 18
- 27
6
votes
3 answers
Android Jetpack Compose - Composable Function get recompose each time Text-field value changes
I'm using TextField to get user input and using stateflow to handle the text state/value in viewmodel.
The thing is everytime textfield value changes HomeContent() function get recomposed.
Layout inspector output image
My question is it ok the whole…

Harsh
- 71
- 1
- 4
6
votes
1 answer
Android Compose Faking Keyboard for specific textfields
I have a screen where some textfields I want to show a 'fake' keyboard. The keyboard should be able have as many buttons as I like and be displayed however I want. Just as shown below.
My question then is how do you accomplish something like…

OscarCreator
- 374
- 4
- 13
6
votes
1 answer
Implementing Long press on Text Jetpack compose
I have a LazyColumn of Text(). I've set clickable for Text() but it's equivalent to OnClickListner. Now I want to set an equivalent of setOnLongClickListener. How can I do that?
@Composable
fun MyText(name: String, modifier: Modifier = Modifier) {
…

TinaTT2
- 366
- 5
- 17
5
votes
1 answer
How to set the width of a row to be equal to width of TextField in Jetpack Compose?
I want the width of the row that contains the button and the text to have the same width as the Text Fields. Here is what I have tried:
Column(
modifier = Modifier.fillMaxSize().padding(padding),
verticalArrangement = Arrangement.Center,
…

Joan P.
- 2,368
- 6
- 30
- 63
5
votes
1 answer
How to write Text into TextFields in a Lazycolumn at the bottom of the screen
I'm having a problem with TextFields inside a LazyColumn.
My goal is to have a LazyColumn with a bunch of TextFields where I can
scroll to see the whole content of the LazyColumn even if the keyboard is active
enter a new line to a TextField and…

F.G.
- 216
- 5
5
votes
2 answers
Jetpack Compose Text Hyphenation
How do I get words to break correctly to new lines in Android with Jetpack Compose? I know the functionality from the web, where I use for such cases.
I defined string values with possible line breaks like this:…

Benjamin Lüscher
- 382
- 3
- 12
5
votes
1 answer
How to open a BasicTextField focused with blinking cursor in it?
I have a BasicTextField in one of my views. I am showing the soft keyboard by default and when I start typing letters on the keyboard, nothing is shown in the BasicTextField, since it has no cursor.
To make my keyboard actions visible, I have to tap…

Ralf Wickum
- 2,850
- 9
- 55
- 103