How to make TextView bold?

I want to make the TextView bold. This is how I set the look (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 in bold?

+4
source share
2 answers
  <!-- Blue Color --> <style name="BlueText"> <item name="android:textColor">#4871A8</item> <item name="android:textStyle">bold</item> </style> 
+11
source

In a related note, if you want to do the same without any XML, you can do this:

TextView myText = new TextView (this);
myText.setTextColor (Color.BLUE);
myText.setTypeface (Typeface.DEFAULT_BOLD);

0
source

All Articles