我在Android 2.2中创建了一个应用程序 我想在Android应用程序的TextView中显示印地文字。 (如何在文本视图中添加“मैंछात्रहूँ”字)如何在Android应用程序中添加字体
请帮助我..
我在Android 2.2中创建了一个应用程序 我想在Android应用程序的TextView中显示印地文字。 (如何在文本视图中添加“मैंछात्रहूँ”字)如何在Android应用程序中添加字体
请帮助我..
添加您的字体资产文件夹中的项目,并使用下面的代码片段
TextView hindiTextView=(TextView)findViewById(R.id.txtbx);
Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf");
mytextView.setTypeface(hindiFont);
希望其很有帮助。
1)加上 “字体” 的字体的内部 “资产” 的文件夹和粘贴字体的内部夹在布局文件夹
2):
<?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/custom_font"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="मैं छात्र हूँ"
/>
3)在活动其中你想设置文本使用下面的代码:
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "hindifont.ttf");
txt.setTypeface(font);
可能重复[如何将外部字体添加到android应用程序(http://stackoverflow.com/questions/5634245/how-to-add-external-fonts-to-android-application) –