Problem in setting font(Family) for Switch (Kotlin Android)

38 Views Asked by At

I have a switch:

<Switch
    android:id="@+id/switch1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="256dp"
    android:showText="true"
    android:checked="true"
    android:textOff="خاموش"
    android:textOn="روشن"
    android:switchTextAppearance="@style/MyStyle"
    android:thumb="@drawable/thumb"
    android:track="@drawable/track"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:ignore="UseSwitchCompatOrMaterialXml" />

MyStyle:

    <style name="MyStyle">
      <item name="android:textColor">@color/black</item>
      <item name="android:textSize">29sp</item>
      <item name="android:textStyle">bold</item>
      <item name="android:fontFamily">@font/iransans</item>
      <item name="fontFamily">@font/iransans</item>
      <item name="font">@font/iransans</item>
    </style>

Other items like textSize set without problem

But still my font "iransans" does not set

Adding android:theme="@style/MyStyle" to Switch, does not solve this problem

Your help will be appreciated

0

There are 0 best solutions below