File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
core/src/main/java/com/github/stephenvinouze/materialnumberpickercore Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ class MaterialNumberPicker : NumberPicker {
6060 field = value
6161 updateTextAttributes()
6262 }
63+ private var fontNameTypeFace: Typeface ? = null
64+
6365 private val inputEditText: EditText ? by lazy {
6466 try {
6567 val f = NumberPicker ::class .java.getDeclaredField(" mInputText" )
@@ -148,11 +150,19 @@ class MaterialNumberPicker : NumberPicker {
148150 inputEditText?.filters = arrayOfNulls(0 )
149151 }
150152
153+ /* *
154+ * Set the font name using your own typeface (example: if you have the font in the resources folder)
155+ */
156+ private fun setFontName (typeface : Typeface ) {
157+ fontNameTypeFace = typeface
158+ updateTextAttributes()
159+ }
160+
151161 /* *
152162 * Uses reflection to access text size private attribute for both wheel and edit text inside the number picker.
153163 */
154164 private fun updateTextAttributes () {
155- val typeface = if (fontName != null )
165+ val typeface = fontNameTypeFace ? : if (fontName != null )
156166 Typeface .createFromAsset(context.assets, " fonts/$fontName " )
157167 else
158168 Typeface .create(Typeface .DEFAULT , textStyle)
You can’t perform that action at this time.
0 commit comments