I have the following composable -
Column(
modifier = modifier
.fillMaxSize()
) {
Row(
modifier = Modifier
.fillMaxWidth()
.wrapContentSize(),
verticalAlignment = Alignment.CenterVertically
) {
TextField(
modifier = Modifier
.weight(1f),
colors = TextFieldDefaults.colors(
focusedContainerColor = getColorFromViewSystem(color = R.attr.colorSecondary),
unfocusedContainerColor = getColorFromViewSystem(color = R.attr.colorSecondary)
),
textStyle = LocalTextStyle.current.copy(
textDirection = TextDirection.Content,
),
value = searchTerm,
onValueChange = { searchTerm ->
onSearchTermChanged(searchTerm)
},
placeholder = {
Text(
modifier = Modifier.weight(1f),
text = stringResource(id = R.string.search_hint),
textAlign = TextAlign.End
)
}
)
// more composables...
}
// more composables...
}
As you can see, on my placeholder variable (equivalent to hint at XML), I have a Text that I am trying to make it aligned to the end of my Text but it doesn't work. I am using RTL language if that matters, and here is the result -
My goal that the hint will move to the left side. What am I missing?

To achieve this behavior, you can use
TextDirectionfromTextStyle. So changing the code it would like this:Note that there's also
TextDirection.ContentOrRtl, as per documentationRtlwill always enable this behavior whileContentOrRtlwill enable RTL when it detects RTL text on first character, so depending on your usecase you may preferContentOrRtl.TextDirection.ContentOrRtlDoc: