5

我在 Android 2.2 中制作了一个应用程序,我想在 Android 应用程序的 TextView 中显示印地语文本。(如何在文本视图中添加“मैं छात्र हूँ”字样)

请帮我..

4

2 回答 2

17

将您的字体添加到项目中的资产文件夹并使用以下代码段

 TextView hindiTextView=(TextView)findViewById(R.id.txtbx);
 Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf");
 mytextView.setTypeface(hindiFont);

希望它有帮助。

于 2011-06-24T04:51:23.343 回答
3

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);  
于 2011-06-24T05:06:14.110 回答