Hi i can delete TextField padding, i am using a OutlinedTextField
a
Hi i can delete TextField padding, i am using a OutlinedTextField
Copy code
OutlinedTextField(modifier = Modifier.padding(0.dp)
    .height(45.dp)
    .width(150.dp), value = textSearch, onValueChange = { search ->
    onInserChanged(search)
}
i
I think you will have to use
BasicTextField
. Please have a look at this blog post https://www.geeksforgeeks.org/how-to-remove-textfield-padding-in-android-using-jetpack-compose/
a
message has been deleted
Ok but i can/t center… cuorsor and text..
Copy code
BasicTextField(value = textSearch ?: "",
    singleLine = true,
    modifier = Modifier.height(36.dp).border(1.dp, GrayKeyBoardLine),
    onValueChange = { search ->
    onSearchChanged(search)
})
message has been deleted
i
try removing the
height
modifier and do this
Copy code
BasicTextField(value = "hello world",
        singleLine = true,
        modifier = Modifier
            .wrapContentSize()
            .border(border = BorderStroke(1.dp, Color.White))
            .padding(2.dp),
        textStyle = TextStyle(textAlign = TextAlign.Center),
        onValueChange = { search ->

        })
however if you would like to have min height to your editText. I suggest you go with a box around
Copy code
Box(
        modifier = Modifier
            .heightIn(min = 36.dp)
            .border(border = BorderStroke(width = 2.dp, Color.White))
            .padding(horizontal = 5.dp, vertical = 2.dp),
        contentAlignment = Alignment.CenterStart
    ) {
        BasicTextField(value = "hello world",
            singleLine = true,
            modifier = Modifier
                .wrapContentSize(),
            onValueChange = { search ->

            })
    }
a
ah.. i have to create a box ? mmm i’d like resolve with only component
i
There is no performance hit with using a box if that’s your concern 😉
m
@Android75 I would say that you shouldn't surround the BasicTextField with a box in the way mentioned above. It has a "decorationBox" parameter specifically for this purpose.
Copy code
BasicTextField(
   ...,
   decorationBox = { innerTextField ->
      Box(...) {
          innerTextField()
      }
   }
)
2000 Views