How do i set the style of a textView programmatically?

lokoko picture lokoko · Feb 22, 2013 · Viewed 40.9k times · Source

I'm creating a textView programmatically. Is there a way that i can set the style of this textView? Something similar to

style="@android:style/TextAppearance.DeviceDefault.Small"

which i would use if i had a layout.xml file.

Answer

Matt picture Matt · Feb 22, 2013

You can't programmatically set the style of a View, but you might be able to do something like textView.setTextAppearance(context, android.R.style.TextAppearance_Small);.