Jake Wilson Jake Wilson - 4 months ago 30
Android Question

Android - set TextView TextStyle programmatically?

Is there a way to set the

textStyle
attribute of a
TextView
programmatically? There doesn't appear to be a
setTextStyle()
method.

To be clear, I am not talking about View / Widget styles! I am talking about the following:

<TextView
android:id="@+id/my_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World"
android:textStyle="bold" />

Answer

Search for setTextAppearance or also setTextTypeface. There is similar question on stackoverflow: How to change a TextView's style at runtime