I want to use a custom font in an Android app but using custom fonts seems to be a pain?! I can setup a custom font programmatically by adding it to each TextView -> lots of boilerplate code. I can create a new class CustomTextView extends TextView and add setTypeface in the constructor -> no xml context aware help for attributes anymore.
Is there another way to setup a custom font? By XML, by style, by theme?
Thanks in advance!
P.S. Is there a possibility to set an underline by XML?
<u>
tags in string resources containing the text that will be assigned toTextView
s. However, I came across some cases where the use of a custom font prevented those tags to work, and the only way to make a text (or a portion of it) underlined was to programmatically useSpannableString
andUnderlineSpan
. See stackoverflow.com/a/10019093/22904 for an example of how to work with those classes. – Giulio Piancastelli