我在开发一个Android 2.2应用程序,在应用程序中我想在TextView中显示印地语文本。(如何将“मैं छात्र हूँ”这个词添加到TextView中)
请帮助我。
我在开发一个Android 2.2应用程序,在应用程序中我想在TextView中显示印地语文本。(如何将“मैं छात्र हूँ”这个词添加到TextView中)
请帮助我。
TextView hindiTextView=(TextView)findViewById(R.id.txtbx);
Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf");
mytextView.setTypeface(hindiFont);
希望这对你有所帮助。
1) 在 "assets" 文件夹内添加一个名为 "fonts" 的文件夹,并将字体粘贴到 "fonts" 文件夹中。
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);