Sharing knowledge

by Oleg Atamanenko

Using custom font in Android TextView

Today I want to share with you custom TextView which allows to set font to be used in xml layout. First, we need to declare our custom styleable attrs.xml: <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="TypefaceTextView"> <attr name="typeface" format="string"/> </declare-styleable> </resources> Then we need to create subclass of TextView which will use custom attribute.