How to set the font of a TextView created at runtime?
I created a TextView
Textview tv = new TextView(this);
tv.setTextSize(20);
you can use your font which you have store in font "res/font" ex. for API level 16 and above.
Typeface typeface = ResourcesCompat.getFont(context, R.font.rubik_medium);
txtView.setTypeface(typeface);
you can also use
Typeface typeface = getResources().getFont(R.font.rubik_medium);
txtView.setTypeface(typeface);
but it support with API level 26 and above.