12

The screenshot below displays my problem.

The first EditText shows a hint in Arabic which is shifted upwards, now the second EditText is just for reference which shows the English version completely fine. Same goes for the Button.

I have declared the string in strings.xml like this:

<string name="ar_login">دخول</string>

screenshot of the problem

This is how I set the EditText's hint:

UserName.setTypeface(ArabicFont);
String hint = getString(R.string.ar_HintUserName);
....
UserName.setHint(hint);

UPDATE: I used this, but of no use:

UserName.setGravity(Gravity.CENTER_VERTICAL);

But with this, Text moved a little down; but i guess its not generic:

UserName.setPadding(0,15,0,0);

With Padding, English words move to downwards.

UPDATE 2: Originally arabic texts are separated; means they are shown letter by letter. So to join them, i was using this Arabic Reshaper. To Download Code, Check this link

Now when i reshape the arabic text and then set on TextView or as EditText's Hint, it got shifted upwords but without reshaping it is fine.

So i guess, whether i have to change the reshape class OR make my textview to not split the word. But dont know where to go?

Farhan
  • 13,290
  • 2
  • 33
  • 59

3 Answers3

3

I am still unable to find out why Android splits the arabic words into separate letters anyhow in my second edit I am providing a link which uses a class to rejoin the separated letters and form a word again.

In the reshape function, it was mistakenly appending \n at the end, just removing it solves the problem.

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
Farhan
  • 13,290
  • 2
  • 33
  • 59
1

I am sure its problem with the font file which you are using.!

[Sorry I am not allowed to upload the screen shot as my reputations are lower :(]

For the layout, I was setting text in xml, and typeface in code. And I'm not setting any attributes like padding/gravity. But it was working fine for me.

So, I can assure you that using font file whose style matches your requirement will solve your problem.

Just to help you out with, but 'm not sure I got font file from DroidSansFallback.ttf

Chandan Adiga
  • 576
  • 4
  • 14
  • With the attached file the results are same. Can you send me the file you were using, on my email address in my profile? i m really unable to solve. i tested with another font file but same result. – Farhan Jul 06 '11 at 08:25
0

Just a guess :) ...,

  1. What if the size of the Arabic font is lower? [If this is the case, then Gravity.CENTER_VERTICAL should have worked for you :( ]

  2. May be this is the style of that font file. How about trying a different font file for Arabic text ?

Chandan Adiga
  • 576
  • 4
  • 14
  • I appreciate but its not working. 1. Font size isn't a issue, but still i checked with gravity thing; same result. 2. Checked with a different font file; same result.. :( – Farhan Jun 30 '11 at 12:08