deano2390 / MaterialShowcaseView

A Material Design themed ShowcaseView for Android
Apache License 2.0
2.72k stars 526 forks source link

Using custom font #113

Open MahdiFarzami opened 7 years ago

MahdiFarzami commented 7 years ago

How can i set custom font to MaterialShowcaseView ?

iman2420 commented 7 years ago

Any Idea??

mimre73 commented 5 years ago

1) create class typeface span `public class TypefaceSpan extends MetricAffectingSpan {

private final Typeface typeface;

public TypefaceSpan(Typeface typeface) { this.typeface = typeface; }

@Override public void updateDrawState(TextPaint tp) { tp.setTypeface(typeface); tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }

@Override public void updateMeasureState(TextPaint p) { p.setTypeface(typeface); p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }

} 2)create a method public static SpannableString typeface(Typeface typeface, CharSequence string) { SpannableString s = new SpannableString(string); s.setSpan(new TypefaceSpan(typeface), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return s; } 3)then .setContentText(typeface("your typeface","your contentText"))`

AmineMessabhia commented 5 years ago

or simply, download the library, make a new method in the builder, and set the Typeface to the textViews. ez