I am facing this issue where `placeholder` and `le...
# compose
m
I am facing this issue where
placeholder
and
leadingIcon
are not properly aligned.
placeholder
is aligned to the top while the
leadingIcon
is in centre. I want both of them to be in centre. What is the solution for this?
t
It is centered. Your placeholder doesn't have any descenders. You can adjust the positioning with
offset
or
paddingFromBaseline
modifiers, but I would check it against text with descenders.
m
Even when I input value to
TextField
, the text is not in centre, it has extra padding from bottom.
Copy code
ProvideTextStyle(
    value = MaterialTheme.typography.body2.copy(
        color = MaterialTheme.colors.primary,
        textAlign = TextAlign.Start
    )
) {
    TextField(
        modifier = Modifier
            .fillMaxWidth(),
        value = field,
        onValueChange = {
            changeField(it)
        },
        maxLines = 1,
        placeholder = placeHolder,
        leadingIcon = leadingIcon,
        trailingIcon = trailingIcon,
        colors = TextFieldDefaults.textFieldColors(
            textColor = MaterialTheme.colors.primary,
            backgroundColor = Color.Transparent,
            focusedIndicatorColor = Color.Transparent,
            unfocusedIndicatorColor = Color.Transparent,
            disabledIndicatorColor = Color.Transparent
        ),
    )
}
This is my code