Material Design implementation in Jetpack compose of a TextField
Questions tagged [android-compose-textfield]
242 questions
13
votes
6 answers
Detect click in Compose TextField
I am trying to implement an onClick handler for a Compose TextField. Current functionality is to handle the TextField click but disable manually editing of the field. For my use case I would like to handle the click and do something else. I would…

lostintranslation
- 23,756
- 50
- 159
- 262
13
votes
2 answers
How to enable capitalization on the virtual keyboard for an Android Compose TextField?
I've recently started moving to Compose to make my UIs in Android. So far I like it, but I'm still struggling to find the right documentation sometimes. So I'm sorry if this question is very obvious!
In the app I'm currently working on, I have a…

raimund89
- 131
- 1
- 7
12
votes
3 answers
Jetpack Compose maxlines on textField is not working
I'm making a todoapp and when im writing the todo i put to only have 1 line, but when i click Enter it creates a new lines, is there any way to fix it?
@Composable
fun TextFieldDemo() {
Column(
Modifier
…

Nunofernandes.official
- 157
- 1
- 7
12
votes
1 answer
Jetpack Compose TextField capture keyboard Enter-input
From what I understand, there is an API for the Jetpack Compose Textfield for capturing Keyboard actions but I don't know what of this APIs that can capture the Enter-Input
The use-case of this capturing enter input is to enable to click Enter and…

Arthur
- 318
- 1
- 4
- 11
12
votes
1 answer
DecorationBox in Jetpack Compose BasicTextField
I use jetpack compose create a editText,I want to show a hint like before "android:hint",
so I try to use decorationBox,but after I created it the input isn't displayed and the log can display my input content.
this is my code,
val passState=…

xinyunlk
- 123
- 1
- 7
12
votes
4 answers
How to remove indicator line of TextField in Androidx Compose Material?
I would like to remove the purple line/indicator (see the following image) of TextField.
Is that possible or should I create my own custom TextField to achieve that?

Agna JirKon Rx
- 2,321
- 2
- 29
- 44
11
votes
4 answers
Android Compose TextField: How to set exact 3 lines
I want to create TextField with exact 3 lines:
I want to see 3 lines even without any text in this TextField, i.e. I need a direct equivalent of EditText.lines in classic xml layout.
My not working code is:
OutlinedTextField(
value =…

anil
- 2,083
- 21
- 37
11
votes
2 answers
Formatting numbers in compose TextField
I am trying to create a reusable NumberField component:
@Composable
fun NumberField(
value: Number?,
onNumberChange: (Number) -> Unit,
) {
TextField(
value = value?.toString() ?: "",
onValueChange = {
it.toDoubleOrNull()?.let {…

lostintranslation
- 23,756
- 50
- 159
- 262
10
votes
1 answer
Removing default padding from TextField in version 1.2.0 includeFontPadding
compose_version = 1.2.0
kotlin 1.7.0
I am trying to remove the TextField. As I am using it with a trailing icon. So I can't use the BasicTextField as it doesn't have the trailing icon.
I am using version 1.2.0 and I was thinking that the…

ant2009
- 27,094
- 154
- 411
- 609
10
votes
1 answer
OutlinedTextField doesn't resize to a minimumWidth in Compose
I'm trying to make an OutlinedTextField (see below image) act as "wrap-content". It would be ideal for it to be just big enough to fit the inside text 500g and expand and contract if user edits the field.
If I remember correctly this was possible to…

David Aleksanyan
- 2,953
- 4
- 29
- 39
10
votes
4 answers
How to clear textfield value in Jetpack Compose?
I've developed a textInput composable with a trailing icon, and I'd like to clear the textInput when the icon is clicked. How can I access the textInput value, so that I can clear it?
@Composable
fun TextInput(
myVal: String,
label:…

Arash Shahzamani
- 245
- 5
- 11
10
votes
3 answers
Change the radius of the border for OutlinedTextField
Is it possible to change the radius of the border of an OutlinedTextField. I want to achieve something like this
I can not use Modifier.border because it just draws border above the label. Like this
And for OutlinedTextField there is no shape…

AnteGemini
- 446
- 6
- 13
9
votes
1 answer
How to get stringResource if not in a composable function
I have a Jetpack Compose app that uses stringResource everywhere and it works great for localization.
But, I have a few functions that are no Composable Functions and I would like to retrieve the string from the resources. When I try to use…

LilMoke
- 3,176
- 7
- 48
- 88
9
votes
1 answer
How to call a composable function in onClick event
This is a composable function. When I click on the CardView then the article should open in the Android view. I'm not sure how how to achieve this.
I also tried it with a lambda but had no success.
I want to call the composable ShowOnWebView…

hemant
- 173
- 2
- 9
9
votes
5 answers
JetPack Compose Button with drawable
How can we achieve this in jetpack compose
I'm doing something like this
Button(
elevation = ButtonDefaults.elevation(
defaultElevation = 0.dp,
pressedElevation = 8.dp,
disabledElevation = 0.dp
),
onClick = {…

Dheeraj Gupta
- 405
- 1
- 4
- 12