Playback starts YouTube’s embedded player (privacy-enhanced mode).
How to Use Custom Fonts as Resources in Android Studio (Incl Toolbar)
ChannelCoding in FlowDescription from the creator
In this tutorial, we will learn how to add custom fonts as resources into our Android Studio project. Unlike downloadable fonts, these local fonts are bundled with the APK and always available offline.
We will also learn how we can bundle multiple fonts together into one font-family XML file, where we can specify a fontStyle and fontWeight for each font file, and let the system apply it to a TextView automatically in accordance to its textStyle (italic or bold).
By adding the fontFamily attribute to the AppTheme instead of a single TextView, we can apply a font application-wide, and by using it on a Toolbar theme, we can change the font of the Toolbar specifically.
We can also change the font of a TextView dynamically in Java code, by creating a Typeface object with getResources().getFont() or the ResourcesCompat compatibility version, and applying this Typeface to a TextView with setTypeface.
Custom fonts are backward compatible down to API level 16 over the AppCompat support library. On API 28 and higher, we can specify the font weight directly over the Typeface.create method or the textFontWeight XML attribute.
Supported font resources are ttf and otf files. We can access the free Google Fonts library directly over the Android Studio Design Editor.
Example code:
gist.github.com/codinginflow/02d13ef838603d9bc4…
____________________
💻 Find the BEST programming tutorials on TutHub:
tuthub.io
⭐ Get my MVVM Caching Course now:
codinginflow.com/caching
❗ Subscribe to the channel:
youtube.com/c/codinginflo...
📨 Subscribe to the Coding in Flow newsletter:
codinginflow.com/newsletter
❓ Join our free developer community:
discord.gg/TSnMvmc
📣 Follow Coding in Flow on other sites:
Facebook: facebook.com/codinginflow
Instagram: instagram.com/codinginflow
TikTok: tiktok.com/@codinginflow
Twitter: twitter.com/codinginflow
Github: github.com/codinginflow
💰 Business requests, sponsoring, etc.: [email protected]
We will also learn how we can bundle multiple fonts together into one font-family XML file, where we can specify a fontStyle and fontWeight for each font file, and let the system apply it to a TextView automatically in accordance to its textStyle (italic or bold).
By adding the fontFamily attribute to the AppTheme instead of a single TextView, we can apply a font application-wide, and by using it on a Toolbar theme, we can change the font of the Toolbar specifically.
We can also change the font of a TextView dynamically in Java code, by creating a Typeface object with getResources().getFont() or the ResourcesCompat compatibility version, and applying this Typeface to a TextView with setTypeface.
Custom fonts are backward compatible down to API level 16 over the AppCompat support library. On API 28 and higher, we can specify the font weight directly over the Typeface.create method or the textFontWeight XML attribute.
Supported font resources are ttf and otf files. We can access the free Google Fonts library directly over the Android Studio Design Editor.
Example code:
gist.github.com/codinginflow/02d13ef838603d9bc4…
____________________
💻 Find the BEST programming tutorials on TutHub:
tuthub.io
⭐ Get my MVVM Caching Course now:
codinginflow.com/caching
❗ Subscribe to the channel:
youtube.com/c/codinginflo...
📨 Subscribe to the Coding in Flow newsletter:
codinginflow.com/newsletter
❓ Join our free developer community:
discord.gg/TSnMvmc
📣 Follow Coding in Flow on other sites:
Facebook: facebook.com/codinginflow
Instagram: instagram.com/codinginflow
TikTok: tiktok.com/@codinginflow
Twitter: twitter.com/codinginflow
Github: github.com/codinginflow
💰 Business requests, sponsoring, etc.: [email protected]
About this tutorial
Coding in Flow published this 16:54 video tutorial on November 9, 2019. It has been watched 96,939 times on YouTube.
- Channel
- Coding in Flow
- Category
- Science & Technology
- Duration
- 16:54
- Published
- November 9, 2019
- Views
- 96,939
- Likes
- 1,332
Tags
Share
This tutorial in other languages
- FRComment utiliser des polices personnalisées comme des ressources dans Android Studio (Incl barre d'outils)
- ES¿Cómo usar fuentes personalizado como Recursos en Android Studio (Incl barra de herramientas)
- PTComo usar fontes personalizado como Recursos em Android Studio (incl Toolbar)
- ITCome utilizzare font personalizzati come risorse in Android Studio (Incl barra degli strumenti)
- DEWie man Use Custom Fonts als Ressourcen in Android Studio (Incl Toolbar)
- NLHoe te gebruiken aangepaste lettertypen als Resources in Android Studio (Incl Toolbar)
- RUКак использовать пользовательские шрифты в качестве ресурсов в Android Studio (включая панель инструментов)
- PLJak używać niestandardowych czcionek jako środki w Android Studio (Incl Toolbar)
- JAどのようにAndroidのStudioのリソースとして利用カスタムフォントに(税込ツールバー)
- ARكيفية استخدام الخطوط المخصصة كما في الموارد الروبوت استوديو (مدفوع شريط أدوات)
- HIकैसे एंड्रॉयड स्टूडियो में संसाधन के रूप में उपयोग कस्टम फ़ॉन्ट्स के लिए (सहित टूलबार)
- IDCara Gunakan Custom Fonts sebagai Resources di Android Studio (Incl Toolbar)