Tom Wilson
Tom Wilson

Reputation: 253

Downloadable font not displaying for Switch TextView

I'm using downloadable fonts for an app, and it's working just fine, however when I've tried to apply the font to the TextView of a Switch, my device won't display it and resorts to the default font - it displays the font correctly for TextViews in the same activity outside of the Switch component.

Strangely, the Android Studio layout design window shows the correct font, but when running on device, it doesn't seem to work correctly.

<Switch
    android:id="@+id/switch1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginEnd="16dp"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    android:fontFamily="@font/baloo_bhai"
    android:text="This is a switch"
    android:theme="@style/AppTheme.Switch"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/editText2" />

This is the display in Android Studio:

Display in Android Studio design window

This is from my device:

Display from device

Upvotes: 0

Views: 869

Answers (1)

Tom Wilson
Tom Wilson

Reputation: 253

It transpires this is a known issue Google Issue #63250768

A fix was located in another StackOverflow question however downloadable fonts will not work with this method - until a resolution, font files must be embedded into the application, as .XML fonts will not work.

Great job, Google!

Upvotes: 1

Related Questions