如何使用ShowcaseView android Library更改标题字体

时间:2014-12-26 07:13:29

标签: android android-fonts showcaseview android-typeface

我在TextDrawer类中尝试了这个但是它不能正常工作

  try {  titleTypeface = Typeface.createFromAsset(context.getAssets(), "Face Your Fears.ttf");

} catch (Exception e) {
// Pretend that never happened, and use the default font
Log.d(TAG, "TITLE FONT: ");
Log.d(TAG, "default font");
}
titlePaint.setTypeface(titleTypeface);
textPaint.setTypeface(titleTypeface);

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

我的TextDrawer构造函数如下所示,适用于我

public TextDrawer(Resources resources, ShowcaseAreaCalculator calculator, Context context) {
    padding = resources.getDimension(R.dimen.text_padding);
    actionBarOffset = resources.getDimension(R.dimen.action_bar_offset);

    this.calculator = calculator;
    this.context = context;

    String fontPath = "fonts/SuperAwesomeFont.ttf";
    Typeface mTypeFace = Typeface.createFromAsset(context.getAssets(),fontPath);

    titlePaint = new TextPaint();
    titlePaint.setAntiAlias(true);
    titlePaint.setTypeface(mTypeFace);

    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setTypeface(mTypeFace);
}