Hebrew And Normal Text Not Displaying Right
Solution 1:
The issue is that you're mixing an rtl and an ltr text in the same string. The system looks at the string to be displays and see it starts with hebrew. So it starts it in RTL mode. It then sees english text. So it switches to LTR. THe result is what you see. You need to put in explicit unicode ltr and rtl marks when mixing languages like this to ensure that its treated correctly. See https://en.wikipedia.org/wiki/Left-to-right_mark for info on ltr marks.
Solution 2:
Sooo... This finally worked for me....
textview.setTextDirection(View.TEXT_DIRECTION_LTR);
Please note that my problem was as I said, Im reading data from a database and not displaying strings, so this code forces all data to be read from left to right, if I do not use this line, It picks up the Hebrew characters as RTL text and wants to display the whole result as RTL.
Thanks for all the help though! I had a lot of reading and learned in the process!
Solution 3:
See the answer here....
I am using the \u200e for right to left
take your string in string.xml
<string name="Yourstring">\u200e שלום</string>
TextView text2=(TextView)findViewById(R.id.text2);
String str= getResources().getString(R.string.Yourstring)+" is the same as hello";
text2.setText(str);
The result as you want
AS you want if you want for database I am adding some demo with the array data you can do these type work with database value
String[] str_array={"שלום is the same as hello","שלום is the same as hello","שלום is the same as hello","שלום is the same as hello"};
TextView text1=(TextView)findViewById(R.id.text1);
TextView text2=(TextView)findViewById(R.id.text2);
TextView text3=(TextView)findViewById(R.id.text3);
TextView text4=(TextView)findViewById(R.id.text4);
Stringstr="";
for(int i=0;i<str_array.length;i++)
{
if(i==0)
{
// before text you want than do this
text1.setText(str.concat("\u200e")+str_array[i]);
}
elseif(i==1)
{
// add this for end of string
text2.setText(str_array[i].concat("\u200e"));
}
elseif(i==2)
{
// before text you want than do this
text3.setText(str.concat("\u200e")+str_array[i]);
}
elseif(i==3)
{
// before text you want than do this
text4.setText(str.concat("\u200e")+str_array[i]);
}
}
The result
Solution 4:
android:supportsRtl="true"
Means you want Right to Left Support for Arabic ,Hebrew Like Language. which is start with RTL Right to left , when System get that Language is Hebrew,it starts with right.As per my Suggestion you need to define that did you really need RTL support in your app. otherwise please set android:supportsRtl="false"
so its start Left to right.
Post a Comment for "Hebrew And Normal Text Not Displaying Right"