Created
March 22, 2022 07:21
-
-
Save SurajBahadur/dbf896d9613661e1144e7c64111a5edc to your computer and use it in GitHub Desktop.
Font Awesome web font in android.
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) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to download fontawesome-webfont.ttf from this link and add it to the asset folder.