2013-08-30 28 views

回答

1

您需要使用字體以支持其他字體。

創建一個名爲資產的新文件夾(如果它不存在)。在其中創建一個名爲字體的新文件夾(僅用於您的簡單)

從互聯網下載'farsi'字體並將其複製到字體文件夾中。

在類文件 create a String to the path of the font.

,並使用此代碼

Typeface tf = Typeface.createFromAsset(getAssets(), fontPath); 
    txt1.setTypeface(tf); 

編輯:一些字體可能在一個移動的支持和在其他它可能不是。例如 例如,我的xperia支持hindi字體,但在我的朋友S2中不支持。

0

首先從鏈接下載中的任何一個的ttf文件,

http://www.neda.net.ir/downloads/fonts/persian.ttf

http://alefba.us/wp-content/plugins/download-monitor/download.php?id=farsifonts-0.4.zip

copy the ttf file into assets folder in your project,, 

首先選擇點擊按鈕

按鈕在代碼中Languge代碼波斯語.setOnClickListener(new View.OnClickListener(){

 @Override 
     public void onClick(View v) { 

      Locale myLocale = new Locale("fa"); 
      Resources res = getResources(); 
      DisplayMetrics dispmetrics = res.getDisplayMetrics(); 
      Configuration conf = res.getConfiguration(); 
      conf.locale = myLocale; 
      res.updateConfiguration(conf, dispmetrics); 
      String current_locale = getResources().getConfiguration().locale.getDisplayName(); 
      System.out.println(current_locale); 
      Intent refresh = new Intent(getBaseContext(), MainActivity.class); 
      startActivity(refresh); 
     } 
    }); 

then below, setContentView(R.layout.activity_main);

   implement this code,,to get the typeFace done 

      String current_locale = getResources().getConfiguration().locale.getDisplayName(); 
    System.out.println("-----"+current_locale); 

    if(current_locale.equals("Persian")) 
    { 

    Typeface font1 = Typeface.createFromAsset(getAssets(), "persian.ttf"); 
    b1.setTypeface(font1); 
    } 

這個解決方案絕對可行,方括號出現在你的手機的原因是由於波斯語的Unicode是不是在你的手機安裝,如果ü要安裝波斯語字體您的手機必須紮根一個

- 感謝

相關問題