If you're writing in Kotlin, this is how you can do it.
First of all, add your font to the font folder.
Then, create a separate Kotlin class. Call it something like HeadlineTextView (or whatever that sort of gives a hint about what the TextView is for).
class HeadlineTextView(context: Context, attributeSet: AttributeSet) : AppCompatTextView(context, attributeSet) {
init {
applyFont()
}
private fun applyFont() {
val headlineTypeface: Typeface=Typeface.create("Montserrat", Typeface.NORMAL)
typeface=headlineTypeface
}
}
Now use this custom Text View in your XML.
Replace this -
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/accountInfoText"
android:textColor="#727272"
android:textSize="18dp" />
With this -
<com.gmail.something.myapp.HeadlineTextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/accountInfoText"
android:textColor="#727272"
android:textSize="18dp" />