2

i'm trying to display an arabic text (Right to Left) in my app, but i get words displayed left to right in lines.

I'm using an arabic supporting font and arabic reshaper lib. The text is loaded from strings file.

The app support Android 2.1.

Here a screen shot for the result:

Arabic Text wrong display

For more details:

enter image description here

public class MainActivity extends Activity {

private TextView tvtest = null;
private static Typeface typeface;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tvtest = (TextView) findViewById(R.id.tvtest);
    tvtest.setText(ArabicUtilities.reshape(getString(R.string.first_part)));
    Typeface tf;
    tf = GetFont(getApplicationContext());
    tvtest.setTypeface(tf);
}

public static final Typeface GetFont(Context context) {
    if (typeface == null) {
        typeface = Typeface.createFromAsset(context.getAssets(),
                // "DroidSansFallback.ttf");
                "MSHQW.TTF");
    }
    return typeface;
}

}

Med_mofid
  • 39
  • 1
  • 1
  • 8

1 Answers1

0

Try to set gravity of your TextView.

in code:

  • `textView.setGravity(...);

or in XML:

  • android:gravity="..."
GIGAMOLE
  • 1,274
  • 1
  • 11
  • 17