Questions tagged [android-compose-textfield]

Material Design implementation in Jetpack compose of a 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…
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…
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 …
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…
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=…
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?
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 {…
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…
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:…
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…
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…
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 = {…
1 2
3
16 17