2015-02-10 33 views
0

我想爲我的android應用程序使用自定義字體,但是我遇到了問題。 我到顯示自定義字體,但該應用程序會顯示兩個textes一個使用默認字體家庭和其他與自定義字體家庭......這似乎重複我TextViewsAndroid:當我使用自定義字體時,TextView被複制

我跟着這個教程:http://blog.goyello.com/2014/08/01/how-to-use-custom-fonts-in-android-apps-and-not-get-fat-3/

不過,我也試圖與這個代碼在我活動的onCreate功能:

TextView txt = (TextView) findViewById(R.id.bloodmatesIntro1); 
Typeface font = Typeface.createFromAsset(getAssets(), "BaroqueScript.ttf"); 
txt.setTypeface(font); 

這個代碼在XML文件

<TextView 
android:id="@+id/bloodmatesIntro1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:text="@string/bloodmates_intro_1"/> 

有什麼不對?

編輯:

我發現下一個代碼(Facebook提供)生成我的問題 https://developers.facebook.com/docs/android/login-with-facebook#step1

if (savedInstanceState == null) { 
    // Add the fragment on initial activity setup 
    mainFragment = new MainFragment(); 
    getSupportFragmentManager() 
      .beginTransaction() 
      .add(android.R.id.content, mainFragment) 
      .commit(); 
} else { 
    // Or set the fragment from restored state info 
    mainFragment = (MainFragment) getSupportFragmentManager() 
      .findFragmentById(android.R.id.content); 
} 

如何使用自定義字體和登錄Facebook在同一個活動?

+1

No code nothing?任何人應該如何幫助? – 2015-02-11 00:01:24

+0

發佈TextView XML和您設置字體的代碼 – 2015-02-11 00:03:52

回答

相關問題