Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android应用程序中添加字体_Android_Textview_Android Fonts - Fatal编程技术网

如何在Android应用程序中添加字体

如何在Android应用程序中添加字体,android,textview,android-fonts,Android,Textview,Android Fonts,我正在用Android 2.2制作一个应用程序 我想在Android应用程序的TextView中显示印地语文本。(如何添加“मैं छात्र हूँ" 文字视图中的文字) 请帮助我。将字体添加到项目中的资产文件夹,并使用以下代码段 TextView hindiTextView=(TextView)findViewById(R.id.txtbx); Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.

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


请帮助我。

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

 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="मैं छात्र हूँ"  
           />  

可能重复它不工作,只显示矩形框,我已经在字体文件夹中包含了vigyapti.ttf文件显示错误..在哪里包含字体文件夹..我包含在资源文件夹中..你必须将其包含到资产文件夹中,如@Jana所说。如果我想在整个应用程序中使用字体怎么办?有没有办法在清单中提到字体?
 TextView txt = (TextView) findViewById(R.id.custom_font);  
 Typeface font = Typeface.createFromAsset(getAssets(), "hindifont.ttf");  
 txt.setTypeface(font);