Android: 当我使用自定义字体时 TextView 重复

Android: TextView is duplicated when I use a custom font

我想为我的 android 应用程序使用自定义字体,但我遇到了问题。 我必须显示自定义字体,但应用程序显示两个文本,一个使用默认字体系列,另一个使用自定义字体系列...它似乎复制了我的 TextViews

我遵循了这个教程:http://blog.goyello.com/2014/08/01/how-to-use-custom-fonts-in-android-apps-and-not-get-fat-3/

不过,我也在 activity 的 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 activity?

问题出在片段中,我不知道为什么它会重复元素,所以我没有创建 MainFragment class,而是按照本教程 http://examples.javacodegeeks.com/core-java/android-facebook-login-example/

现在,我可以同时使用自定义字体和 facebook 登录 activity。