Loading...

How to Change fontFamily of Android TextView

You can easily change the font of your android application using fontFamily. You can use default fonts directly with android:fontFamily att...

You can easily change the font of your android application using fontFamily. You can use default fonts directly with android:fontFamily attribute like sans-serif, sans-serif-medium etc. If you want to use some custom font from the internet in your app TextView, Button, EditText I have already published a post on How to Use Custom Fonts in Android Application.

In this tutorial, you will learn to set font family in your android app textview, button etc. To use custom font (other than default) you have to use Typeface in java code.


Related:
How to Use Custom Fonts in Android Application
How to Use Font Awesome Icons in Android Application
How to Make Multiple Styles Inside Android TextView

Android Example: Change fontFamily of Android TextView


Following is the example code of XML layout file to change the font family in android application programmatically.

XML Layout File


Here I have added five text views with different font family.

res/layout/android_change_fontfamily_in_textview.xml

Android Example: Change fontFamily of Android TextView

Following are the some default fonts which you can directly use in your application.

android:fontFamily="sans-serif"
android:fontFamily="sans-serif-light" 
android:fontFamily="sans-serif-condensed”
android:fontFamily="sans-serif-thin" 
android:fontFamily="sans-serif-medium”
If you want to use a specific font everywhere in your application you can set it in your app styles.xml file.

Now, run your How to Change fontFamily of Android TextView application, you will see different fonts in different text view.
XML 5858088548217466077
Home item