Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit e310730

Browse files
committed
added custom font support
1 parent c8c9c1e commit e310730

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

loadingbutton/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
minSdkVersion 15
1414
targetSdkVersion 28
1515
versionCode 1
16-
versionName "0.1.2"
16+
versionName "0.1.4"
1717

1818
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1919

loadingbutton/src/main/java/com/droidbond/loadingbutton/LoadingButton.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.graphics.PorterDuff
77
import android.graphics.Typeface
88
import android.support.annotation.NonNull
99
import android.support.annotation.Nullable
10+
import android.support.v4.content.res.ResourcesCompat
1011
import android.util.AttributeSet
1112
import android.util.Log
1213
import android.view.Gravity
@@ -96,7 +97,13 @@ class LoadingButton @JvmOverloads constructor(
9697
var size = array!!.getDimension(R.styleable.app_textSize, 14f * Resources.getSystem().displayMetrics.density)
9798
size /= Resources.getSystem().displayMetrics.density
9899

99-
tvText!!.textSize = size
100+
tvText?.textSize = size
101+
102+
if (array!!.hasValue(R.styleable.app_customFontFamily)) {
103+
val fontId = array!!.getResourceId(R.styleable.app_customFontFamily, -1)
104+
val typeface = ResourcesCompat.getFont(context, fontId)
105+
tvText?.typeface = typeface
106+
}
100107

101108
array?.recycle()
102109
}

loadingbutton/src/main/res/values/styles.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<attr name="textSize" format="dimension"/>
88
<attr name="progressColor" format="color"/>
99
<attr name="background" format="reference"/>
10+
<attr name="customFontFamily" format="reference"/>
1011
<attr name="progressBarSize" format="enum">
1112
<enum name="large" value="64"/>
1213
<enum name="medium" value="48"/>

0 commit comments

Comments
 (0)