Custom TypeFace in Kotlin Programmatically

Rahul Khurana picture Rahul Khurana · May 30, 2017 · Viewed 8.9k times · Source

How to set typeface of any TextView. Using java we do something like this

TextView tv = (TextView) findViewById(R.id.custom);
tv.setTypeface(null, Typeface.BOLD);

How such operation could be performed while using kotlin. Which will be the efficient way to do this in kotlin? Is there any better way provided with kotlin?

holder.itemView.title.typeface = ?

Answer

Rahul Khurana picture Rahul Khurana · May 30, 2017

Thanks after lot of research i solved it in single line

holder.itemView.title.typeface = Typeface.DEFAULT_BOLD

Hope it helps someone else !!