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

Commit

Permalink
added custom font support
Browse files Browse the repository at this point in the history
  • Loading branch information
islamdidarmd committed Nov 25, 2018
1 parent c8c9c1e commit e310730
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion loadingbutton/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "0.1.2"
versionName "0.1.4"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.graphics.PorterDuff
import android.graphics.Typeface
import android.support.annotation.NonNull
import android.support.annotation.Nullable
import android.support.v4.content.res.ResourcesCompat
import android.util.AttributeSet
import android.util.Log
import android.view.Gravity
Expand Down Expand Up @@ -96,7 +97,13 @@ class LoadingButton @JvmOverloads constructor(
var size = array!!.getDimension(R.styleable.app_textSize, 14f * Resources.getSystem().displayMetrics.density)
size /= Resources.getSystem().displayMetrics.density

tvText!!.textSize = size
tvText?.textSize = size

if (array!!.hasValue(R.styleable.app_customFontFamily)) {
val fontId = array!!.getResourceId(R.styleable.app_customFontFamily, -1)
val typeface = ResourcesCompat.getFont(context, fontId)
tvText?.typeface = typeface
}

array?.recycle()
}
Expand Down
1 change: 1 addition & 0 deletions loadingbutton/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<attr name="textSize" format="dimension"/>
<attr name="progressColor" format="color"/>
<attr name="background" format="reference"/>
<attr name="customFontFamily" format="reference"/>
<attr name="progressBarSize" format="enum">
<enum name="large" value="64"/>
<enum name="medium" value="48"/>
Expand Down

0 comments on commit e310730

Please sign in to comment.