Search code examples
fontstextviewwear-os

Wear OS custom fonts are not loaded at all


I have an Wear 2.0 Activity and a TextView which uses a custom font. When deploy the app to wear devices the font is not loaded, using real device LG Urbane 2(on simulator is loaded ok). Tried with different custom fonts. I have set the custom font in app style level and in activity layout textview. Text size is set to 16sp. AndroidX imports used.

<item name="android:fontFamily">@font/lalezar</item>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/lalezar"/>

Font used:​ Lalezar-Regular.ttf etc...

I am doing something wrong? Did anyone found a solution?


Solution

  • It's not documented AFAICT, but it seems that specifying fontFamily in layout XML doesn't work on Wear OS.

    Applying the font programmatically does work, however. Just get a reference to your TextView in Java/Kotlin, then:

    myTextView.setTypeface(ResourcesCompat.getFont(context, R.font.lalezar));