Here is the XML:
Most of the answers are correct.
You can also use the so called : SpannableString
You can use it this way :
String bold = "yes !";
String notBold = "no ";
SpannableString text = new SpannableString ( notBold + bold );
text.setSpan ( new StyleSpan ( Typeface.BOLD ) , notBold.length () , text .length () , 0 );
myTextView.setText ( text , BufferType.SPANNABLE );
What is nice about the SpannableString is that you can apply mutliple spans, each on different parts of the string ! As you noticed, I applied the bold type face only on a part of the string (you specify the start and end indexes) , and it should look like this :
no yes !
In the method setSpan, you specify the SPAN to apply, the starting index, the ending index, and flags (I always use 0), in that specific order.
You can even apply other spans, like change the text size (use RelativeSizeSpan ), or even color (use ForegroundColorSpan ), and much more !
Here is an example for the color span, that you can achieve in the following manner :
text.setSpan ( new ForegroundColorSpan ( Color.RED) , 0 , notBold .length () , 0 );
And now, the first part of the string (containing the word no) will be displayed in red !