1

I write an application in Hebrew but there is a problem with the direction of the words:

This is the code:

textView2.setText("יצרן: " + company + "\n");
textView2.append("דגם: " + degem + "\n");
textView2.append("מנוע: " + manoa + "\n");
textView2.append("ק'מ/ליטר: "+  watt + "\n");
textView2.append("נסיעה: " + timeString + " " + timeMedida+"\n");

I got:

יצרן:ABARTH

instead of

ABARTH:יצרן

and

דגם:005

instead of

דגם:500

the xml:

<TextView
    android:id="@+id/txt_1_delek"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
            android:gravity="center"


    android:layout_marginTop="50sp"
    android:layout_marginRight="100sp"
    android:layout_marginLeft="100sp"
    android:text="myTextView"/>
j0k
  • 22,600
  • 28
  • 79
  • 90
user1462787
  • 659
  • 2
  • 12
  • 20

1 Answers1

1

In case someone stumbles upon this old question and is looking for an answer... Amir's link points toward the right direction. What you need is to change the text's base direction (and not the alignment, so as explained in the link "gravity.RIGHT" wont help there). Inserting the "left mark" unicode character \u200F at the beginning of your string will do the trick.

BTW just adding it as a hardcoded character didn't work for me, apparently because of encoding issues. I prefered to avoid dealing with it in the code, so i simply extract the character as a string from strings.xml, let android do the conversion as it wishes, and append the string (in your case "יצרן: " + company + "\n") in realtime.

tangerine
  • 836
  • 1
  • 8
  • 14