阿拉伯语言错误显示:从左到右

时间:2015-02-02 16:57:40

标签: android arabic

我正在尝试在我的应用中显示阿拉伯语文字(从右到左),但我会在行中从左到右显示单词。

我正在使用阿拉伯语支持字体和阿拉伯语重塑器库。文本从字符串文件加载。

该应用支持Android 2.1。

这里是结果的屏幕截图:

Arabic Text wrong display

更多详情:

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;
}

}

1 个答案:

答案 0 :(得分:0)

尝试设置TextView的重力。

代码:

  • `textView.setGravity(...);

或XML格式:

  • android:gravity="..."