Skip to content

Commit

Permalink
Merge pull request #7 from kukadiajayesh/hotfix/TextSizeImprovments
Browse files Browse the repository at this point in the history
Improve text size method
  • Loading branch information
kukadiajayesh authored Dec 22, 2020
2 parents 176cdc8 + b26fe60 commit 0af83d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.github.therajanmaurya.sweeterror
import android.content.Context
import android.graphics.PorterDuff
import android.graphics.Typeface
import android.util.TypedValue
import android.util.TypedValue.COMPLEX_UNIT_PX
import android.view.View
import android.widget.*
import androidx.annotation.ColorRes
Expand Down Expand Up @@ -218,7 +220,7 @@ class SweetUIErrorHandler(private val context: Context, private val view: View)
* Set Custom feature text size
*/
fun setCustomFeatureTextSize(@DimenRes textSizeRes: Int) {
tvCustomFeatureName.textSize = context.resources.getDimension(textSizeRes)
tvCustomFeatureName.setTextSize(COMPLEX_UNIT_PX, context.resources.getDimension(textSizeRes))
}

/**
Expand All @@ -243,7 +245,7 @@ class SweetUIErrorHandler(private val context: Context, private val view: View)
* Set Custom Sub feature text size
*/
fun setCustomSubFeatureTextSize(@DimenRes textSizeRes: Int) {
tvCustomSubFeatureName.textSize = context.resources.getDimension(textSizeRes)
tvCustomSubFeatureName.setTextSize(COMPLEX_UNIT_PX, context.resources.getDimension(textSizeRes))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class SweetErrorInActivity : AppCompatActivity() {

sweetUIErrorHandler.setBackgroundColor(R.color.light_blue)
sweetUIErrorHandler.showCustomFeatureImage(false)
sweetUIErrorHandler.setCustomFeatureTextSize(R.dimen.text_size_20sp)
sweetUIErrorHandler.setCustomSubFeatureTextSize(R.dimen.text_size_14sp)

sweetUIErrorHandler.setCustomFeatureImageTintColor(R.color.colorAccent)
sweetUIErrorHandler.setCustomFeatureTextTypeFace(ResourcesCompat.getFont(this, R.font.nunito)!!)
sweetUIErrorHandler.setCustomSubFeatureTextTypeFace(ResourcesCompat.getFont(this, R.font.nunito)!!)
Expand Down

0 comments on commit 0af83d6

Please sign in to comment.