0
votes

I have a TextView that I want to style. I know that sans-serif font family uses the font Roboto.

<TextView
    android:fontFamily="serif"/>

I only get the following suggestions for fontFamily:

  • serif
  • serif-monospace
  • sans-serif
  • sans-serif-condensed
  • sans-serif-smallcaps

How do you use the rest of the aliases declared in /system/etc/font.xml?

<familyset version="22">
    ...
    <!-- Note that aliases must come after the fonts they reference. -->
    <alias name="sans-serif-thin" to="sans-serif" weight="100" />
    <alias name="sans-serif-light" to="sans-serif" weight="300" />
    <alias name="sans-serif-medium" to="sans-serif" weight="500" />
    <alias name="sans-serif-black" to="sans-serif" weight="900" />
    <alias name="arial" to="sans-serif" />
    <alias name="helvetica" to="sans-serif" />
    <alias name="tahoma" to="sans-serif" />
    <alias name="verdana" to="sans-serif" />
    ...
</familyset>
1

1 Answers

0
votes

Turns out, alias tags are not being "scanned" by Android Studio so they appear in suggestions dropdown. Doing like so is okay:

<TextView
    android:fontFamily="sans-serif-black"/>

Cheers!