Add Font Awesome

Using https://github.com/finnmglas/fontawesome-android
This commit is contained in:
Finn M Glas 2020-05-20 22:05:08 +02:00
parent 92e8cbd450
commit 7cd450f897
5 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,93 @@
package com.finnmglas.launcher // replace with your package
// On GitHub: https://github.com/finnmglas/fontawesome-android
import android.content.Context
import android.graphics.Typeface
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
class FontAwesomeSolid : 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()
}
private fun init() {
typeface = Typeface.createFromAsset(
context.assets,
"fontawesome/fa-solid-900.ttf"
)
}
}
class FontAwesomeRegular : 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()
}
private fun init() {
typeface = Typeface.createFromAsset(
context.assets,
"fontawesome/fa-regular-400.ttf"
)
}
}
class FontAwesomeBrand : 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()
}
private fun init() {
typeface = Typeface.createFromAsset(
context.assets,
"fontawesome/fa-brands-400.ttf"
)
}
}