I would like to achieve similar behaviour with TextField
from Jetpack Compose like from old school XML layout:
<EditText
android:id="@+id/some_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right" /> <!-- or end -->
When I try this approach:
TextField(value = "", onValueChange = {
}, textAlign = TextAlign.End)
It simply just doesn't work because textAlign
property doesn't exists in TextField
. Then how to do input text alignment like TextAlign.Center
, TextAlign.End
, TextAlign.Justify
and so on for TextField
?
You can do it through textStyle
.
TextField(
value = "",
onValueChange = {
},
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.End)
)
LocalTextStyle.current
is the default value for TextField
, you can replace it by your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With