Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the font of tabLayout with a custom font / calligraphy

Tags:

java

android

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

I tried this but it didnt work

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

            textViewToConvert.setTypeface(hero);
        }
    }
like image 398
Alpoe Avatar asked Aug 11 '17 22:08

Alpoe


People also ask

How to change typing style on phone?

Tap on the "Display" and then the "Font and screen zoom" Scroll down the screen up to "Screen Zoom" and "Font Style." Under the "Screen Zoom" section, you can change the font size that you wish. Under the "Font Style" section, you can choose font style from the available list to set it as the system font.

Which app can change font style in phone?

HiFont is one of the most effective font changer apps for Android. It supports various devices, from smartphones to tablets running Android. There are a lot of awesome free fonts to be downloaded on your Android device.


1 Answers

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 style 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>
like image 136
EslamWael74 Avatar answered Sep 28 '22 05:09

EslamWael74