Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetpack compose TextField RTL support

XML TextField, automatically response to RTL text and align it to right.

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/textview_first"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="سلااااااممممممم"
        app:layout_constraintBottom_toTopOf="@id/button_first"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

1 * 2

But, In Compose TextField, it's stick to left. Is there any way to have TextField to align RTL text to right and LTR text to left?

like image 656
Kaaveh Mohamedi Avatar asked Mar 04 '26 09:03

Kaaveh Mohamedi


1 Answers

Based on @Poran answer, you must add textStyle to TextField :

TextField(
   value = name,
   ...
   textStyle = TextStyle(color = Color.Black, textDirection = TextDirection.Content)
)
like image 144
Kaaveh Mohamedi Avatar answered Mar 07 '26 00:03

Kaaveh Mohamedi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!