zalewski.se
06/21/2020, 2:18 PMTextField
to the right side of the screen? I’m trying to use ConstraintLayout
for this, where everything looks as expected with Text
element, but when I changed it to TextField
it looks like the:
right constrainTo parent.right
doesn’t work 🤔
To give you some code:
This is sample with `Text`:
ConstraintLayout(
modifier = Modifier.fillMaxWidth().wrapContentHeight(),
constraintSet = ConstraintSet {
tag("amountTag").apply {
right constrainTo parent.right
right.margin = 16.dp
horizontalBias = 1.0f
centerVertically()
}
}
) {
Text(
modifier = Modifier.tag("amountTag"),
fontSize = 16.sp,
text = rate.value.toString()
)
}
And when I just changed Text
to `TextField`:
TextField(
modifier = Modifier.tag("amountTag"),
value = value,
onValueChange = {
value = it
}
)
Also I tried to add some modifiers to TextField
like: .wrapContentWidth(Alignment.End)
but same result.Anastasia [G]
06/21/2020, 10:20 PMbackground()
modifier to the TextField to see how much space it occupies.
If this is indeed the case, then you could either try to make TextField wrap the content by setting the minimum width to something other than 0 (e.g. preferredWidthIn(minWidth = 5.dp)
). Or you could align the input text within the TextField to the right (using the textAlign
param of the TextStyle param of the TextField).zalewski.se
06/22/2020, 2:40 PM