以下是Android中Bangla的代码:
package com.exam;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class TextDifferentActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Typeface tf = Typeface.createFromAsset(getAssets(),
"fonts/DroidSansFallback.ttf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setTypeface(tf);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/DefaultFontText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Here is some text." />
<TextView
android:id="@+id/CustomFontText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="আল্লাহ">
</TextView>
</LinearLayout>
这里显示আ্ললাহ。但我需要将其显示为আল্লাহ。我该如何解决这个问题? 在我的手机HTC A3333中,它会显示字体。还有其他解决方案可以使其正确吗?
答案 0 :(得分:2)
无论你做什么,复杂的字形(juktoborno)总是显示为破碎的字符,我发现的解决方案只是使用图像。你可以使用 SpannableStringBuilder 来实现这个目的。但是仅仅为juktoborno使用图像并不完美,因为图像不能与字体字符完全同步,如下所示:
所以你需要用图像替换所有字符,这样就不需要图像。但是使用 Overlay 技术可以大大减少图像数量。这就是我最终取得的成就: