Jump To Right Section
Show
In this article, we discuss How to use a custom font in Android Studio programmatically. Before we get started, if you want to know about some essential Tips and Tricks for android development, please go through the following article: Tips and Tricks Android App Developers.
Download your desire font
First, I download my fonts in .ttf format and I use the dafont.com site to download fonts. Here are the Steps for applying custom fonts on TextView and using this approach you can apply fonts on every TextView or EditText.
- Go to the (project folder) Then app>src>main
- Create folders named ‘assets/fonts’ into the main folder.
- Put your fonts into the fonts folder. Here I Have ‘myfont.ttf’
Method with AsseetManager
1 2 3 4 5 |
AssetManager am = context.getApplicationContext().getAssets(); typeface = Typeface.createFromAsset(am, String.format(Locale.US, "fonts/%s", "myfont.ttf")); setTypeface(typeface); |
Alternative Method
1 2 3 4 5 6 7 8 9 10 11 12 13 |
TextView txtAppsName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); txtAppsName=(TextView)findViewById(R.id.textAppName); Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/myfont.ttf"); txtAppsName.setTypeface(typeFace); } |
How to use custom font in Android Studio
The article was published on October 24, 2016 @ 3:12 PM
Leave a Comment