Material Design implementation in Jetpack compose of a TextField
Questions tagged [android-compose-textfield]
242 questions
1
vote
4 answers
jetpack compose can't set search bar background color to white
I have a search bar with textfield when I try to set background color to white it comes with gray but I can make it to other colors only white not working if I change Textfiled to BasicTexfield it works fine but can't set the Icon top…

YUSUF AYDIN
- 33
- 5
1
vote
1 answer
Why does Android Studio Kotlin Compose Template display text wrong when app is run?
I built an app from the Android Studio template using the new Compose feature (official docs).
The Preview looks like the following:
However, when I run the application, it looks like this (text is much smaller & is not centered in the View):
Is…

raddevus
- 8,142
- 7
- 66
- 87
1
vote
3 answers
Text in Border using Jetpack Compose
I want to add text in the border as following. The border enclosing text has a icon in it
Can someone please suggest how to approach this?

Devesh Mittal
- 169
- 1
- 7
1
vote
2 answers
Compose TextField shows wierd behavior
I am trying to implement a TextField which inputs an amount and formats it as soon as it is typed and also limits it to 100,000.
@Composable
fun MainScreen(
viewModel: MyViewModel
) {
val uiState by viewModel.uiState.collectAsState()
…

Arpit Shukla
- 9,612
- 1
- 14
- 40
1
vote
2 answers
is there a way to change the background color of a specific word in outlined text field jetpack compose?
I am looking for a way to change the background color of certain words in outlined text field while typing, but I couldn't find a way to achieve that yet. Does anyone know a way to do this? (Preferably in compose but other solutions are also OK.)
user14113746
1
vote
1 answer
How to know when a Composable like TextField gains focus?
I want to trigger a function upon my TextField's focus-gain, but I am unable to find something like a listener.

Richard Onslow Roper
- 5,477
- 2
- 11
- 42
1
vote
1 answer
Align Textfield label to start of underbar using Jetpack Compose
By default the label of Textfield is not aligned with the start position of underbar. There seems to be some empty space before the label text.
This is how my Textfields look like:
I want the label of my textfield to be aligned to the start…

Sparsh Dutta
- 2,450
- 4
- 27
- 54
1
vote
1 answer
Is there anyway to center text within a TextField horizontally and vertically?
In Android compose is there anyway to center text within a TextField?
TextField(
value = text,
onValueChange = setText,
maxLines = 2,
modifier = modifier
.clip(RoundedCornerShape(10.dp))
…

Lucas
- 323
- 1
- 8
1
vote
1 answer
Jetpack Copmose, center text in TextField
Is it possible to center text in TextField?
textStyle = TextStyle(textAlign = TextAlign.Center) seems not working.

Solvek
- 5,158
- 5
- 41
- 64
1
vote
1 answer
TextField not updating when applying State Hoisting
I am building a simple app following Mitch Tabian's youtube tutorial about Jetpack Compose.
In the State Hoisting video, he extracts the code for the search TextField into a separate Composable. When I do so, my textField doesn't update the value…

Praveen P.
- 976
- 2
- 11
- 23
0
votes
0 answers
(Jetpack compose) In TextField when I try to paste text the cursor moves up or down and selects text above or below it
TextField(
value = text,
onValueChange = {
myViewModel.setText(it)},
label = null,
placeholder = {
Text(
…

Katarina Zivkovic
- 11
- 3
0
votes
2 answers
Prevent Text overlapping button in Compose Android
I created the view as below:
@Composable
fun DynamicMessageBanner(
title: String,
message: String,
clickableText: AnnotatedString,
onClickableTextClicked: () -> Unit,
onCloseClicked: () -> Unit
) {
Card(
modifier =…

Long Dao
- 1,341
- 4
- 15
- 33
0
votes
1 answer
Restrict only numbers, commas(,) or only one dot(.) using Regex for TextField Jetpack compose
I am working on customizing TextField in Jetpack Compose, I want restrict the input from the user to numbers, commas or a single dot.
The regular expression that I am currently using is val expression = Regex("[\\d,.]+") . It works fine for numbers…

Arshdeep_somal
- 206
- 1
- 13
0
votes
1 answer
Keyboard flickering when programmatically hidden in Jetpack Compose
When I programmatically hide the keyboard which is focused on the TextField, it flickering. How to get rid of this?
val keyboardController = LocalSoftwareKeyboardController.current
var text by rememberSaveable { mutableStateOf("") }
TextField(
…

Mikhail
- 2,612
- 3
- 22
- 37
0
votes
0 answers
Jetpack Compose does not pass the correct constraints to its children
I tested the following code on a physical phone, HUAWEI GR5 KII-L21, running Android Lollipop.
@Composable
fun MainScreen() {
val metrics = LocalContext.current.resources.displayMetrics
println("the width is ${metrics.widthPixels}")
…

ntos
- 189
- 10