From b26fe60fbcab99cd1348b9ecc164401ff35f523b Mon Sep 17 00:00:00 2001 From: Jayesh Date: Tue, 22 Dec 2020 13:06:49 +0530 Subject: [PATCH] Fix: set textsize in pixel --- .../github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt | 6 ++++-- .../therajanmaurya/sweeterror/demo/SweetErrorInActivity.kt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt b/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt index 8660694..b86492b 100644 --- a/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt +++ b/Sweet-Error/src/main/java/com/github/therajanmaurya/sweeterror/SweetUIErrorHandler.kt @@ -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 @@ -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)) } /** @@ -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)) } /** diff --git a/app/src/main/java/com/github/therajanmaurya/sweeterror/demo/SweetErrorInActivity.kt b/app/src/main/java/com/github/therajanmaurya/sweeterror/demo/SweetErrorInActivity.kt index fbefd16..5eb26ea 100644 --- a/app/src/main/java/com/github/therajanmaurya/sweeterror/demo/SweetErrorInActivity.kt +++ b/app/src/main/java/com/github/therajanmaurya/sweeterror/demo/SweetErrorInActivity.kt @@ -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)!!)