Font awesome web font in android
You have to download fontawesome-webfont.ttf from this link and add it to the asset folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextViewFontAwsome : androidx.appcompat.widget.AppCompatTextView { | |
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context!!, attrs, defStyle) { | |
init() | |
} | |
constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) { | |
init() | |
} | |
constructor(context: Context?) : super(context!!) { | |
init() | |
} | |
fun init() { | |
try { | |
val tf = Typeface.createFromAsset(context.assets, "fontawesome-webfont.ttf") | |
typeface = tf | |
} catch (exp: Exception) { | |
} | |
} | |
} |
No comments :
Post a Comment