How to make a TextView bold?

Sheehan Alam picture Sheehan Alam · Sep 28, 2010 · Viewed 9.4k times · Source

I want to be able to make a TextView bold. This is how I am setting it's appearance (I need to do this in code):

nameText.setTextAppearance(getApplicationContext(), R.style.BlueText);
priceText.setTextAppearance(getApplicationContext(), R.style.BlueText);
changeText.setTextAppearance(getApplicationContext(), R.style.BlueText);

Here is my style.xml

  <!-- Blue Color -->
   <style name="BlueText">
        <item name="android:textColor">#4871A8</item>
    </style>

How can I make sure my TextView is bolded?

Answer

Cristian picture Cristian · Sep 28, 2010
  <!-- Blue Color -->
   <style name="BlueText">
        <item name="android:textColor">#4871A8</item>
        <item name="android:textStyle">bold</item>
    </style>