【问题标题】:How to Change title font with ShowcaseView android Library如何使用 ShowcaseView android 库更改标题字体
【发布时间】:2014-12-26 07:13:29
【问题描述】:

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

有什么建议吗?

【问题讨论】:

    标签: android android-fonts showcaseview android-typeface


    【解决方案1】:

    我的 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);
    }
    

    【讨论】:

    • 是的。这也对我有用。我的代码的错误是我将样式文件中的字体更改为衬线,因此代码中的字体设置不起作用
    猜你喜欢
    • 1970-01-01
    • 2015-03-01
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    相关资源
    最近更新 更多