2014-12-26 67 views
1

我想这在TextDrawer类,但它不工作如何更改标题字体与ShowcaseView的Android库

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); 

有什么建议?

回答

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); 
} 
+0

雅。这也适用于我。我的代码中的错误是我将我的字体从样式文件更改为serif,所以代码中的字体设置不起作用 – bpr10