How to change the font of tablayout using custom font / calligraphy

I'm looking for answers on how to change the fonts of these tabs in tablayout to custom fonts

I tried this, but it didn't work

 Typeface hero = Typeface.createFromAsset(getContext().getAssets(),"fonts/Hero Light.otf");

            textViewToConvert.setTypeface(hero);
        }
    }

resolvent:

In your layout

<android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        style="@style/Tab"
        android:layout_width="match_parent"
        android:layout_height="54dp"
        app:tabTextAppearance="@style/mineCustomTabText"/>

And in your styles folder

<style name="mineCustomTabText" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">12sp</item>
    <item name="android:textAllCaps">true</item>
    <item name="android:fontFamily">@font/two_light_1</item>
</style>

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>