如何使用自定义字体/书法更改tabLayout的字体 [英] How to change the font of tabLayout with a custom font / calligraphy

查看:372
本文介绍了如何使用自定义字体/书法更改tabLayout的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有关如何将TabLayout中这些标签的字体更改为自定义字体的答案。

I was looking for answers about how I can change the fonts of those tabs in that TabLayout to a custom font.

我试过这个但是没有用

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

            textViewToConvert.setTypeface(hero);
        }
    }


推荐答案

在您的布局中

<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"/>

并在你的样式文件夹中

<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>

这篇关于如何使用自定义字体/书法更改tabLayout的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆