How to make the text direction from right to left

前端 未结 12 712
时光取名叫无心
时光取名叫无心 2020-11-29 01:00

I want to write text in (right to left language i.e. Arabic) in a TextView. But I want to make the text writing direction from right to left. gravity:rightwill

相关标签:
12条回答
  • 2020-11-29 01:26

    Add these to your editText:

    android:gravity="right"
    android:textDirection="rtl"
    

    PS: android:textDirection requires API level 17

    0 讨论(0)
  • 2020-11-29 01:31

    set this line in xml for textview :

     android:textDirection="locale"
    
    0 讨论(0)
  • 2020-11-29 01:31

    Try using

     textview.setTextDirection(View.TEXT_DIRECTION_RTL);
    

    or

     textview.setTextDirection(View.TEXT_DIRECTION_ANY_RTL);
    
    0 讨论(0)
  • 2020-11-29 01:32

    try this as it worked for me android:textDirection="rtl"

    0 讨论(0)
  • 2020-11-29 01:32

    By using attributes as below in my xml code strangely I got a right to left text with correct punctuation. But this is not a perfect solution for multi language text:

    android:textDirection="ltr"
    android:gravity="right"
    

    setting ltr corrects punctuation problems like having dot on right side instead of left.

    gravity attribute makes text flow from right to left.

    0 讨论(0)
  • 2020-11-29 01:33

    just adding my own experience with such issues. in my case in addition to suggested solutions i also had to replace English " character with the RTL (in my case hebrew) representation of such character ״

    0 讨论(0)
提交回复
热议问题