A CustomTextView class which removes the need for applying the custom fonts for each TextView
==============
Implementation:
-
Under
/res/values/folder createattrs.xmlfile with the following cotents:<declare-styleable name="Fonts"> <attr name="fontName" format="string"> </attr> </declare-styleable> -
Add your desired fonts in
/assetsfolder like "Politica XT.otf" font
==============
Usage:
Simply set the fontName attribute to an EXISITING font file name in your assets folder
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mylibrary.FancyTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test text"
android:id="@+id/testcustomview"
app:fontName="ProximaNova-Bold.otf"
/>
</LinearLayout>