3
Typeface robotoBold = Typeface.createFromAsset(activity.getAssets(),
        "fonts/Roboto-Bold.ttf");
Typeface robotoLight = Typeface.createFromAsset(activity.getAssets(),
        "fonts/Roboto-Light.ttf");


SpannableStringBuilder sb = new SpannableStringBuilder("This must be BOLd\nThis must be NORMAL");
sb.setSpan(robotoBold, 0, 17, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(robotoLight, 18, 37, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
mTextView.setText(sb);

This gives me a normal text for the whole TextView.

Thank You.

Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226

2 Answers2

0

We are able to do this functionality

font for part of a Text

you have to use alter net like take two textview and divide your text and set that text.

or use

spannable text

J.D.
  • 1,401
  • 1
  • 12
  • 21
  • "We are not able to do this functionality". Oh yes we are. – Simon Nov 05 '12 at 09:23
  • @Simon i also address spannable text if you have answer then give answer. – J.D. Nov 05 '12 at 09:31
  • The answer has already been given. But I see what you mean. However, the statement is incorrect. Spannable text is perfectly able to do this. – Simon Nov 05 '12 at 09:38
-3
mTextView.setText("This must be BOLd\nThis must be NORMAL");
Spannable span = new SpannableString(mTextView.getText());
span.setSpan(robotoBold,0,17,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
span.setSpan(robotoLight,18,37,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
mTextView.setText(span);
Carl K.
  • 457
  • 4
  • 16
  • Otherwiseuse this mTextView.setText("This must be BOLd\nThis must be NORMAL"); Spannable span = new SpannableString(mTextView.getText()); span.setSpan(new RelativeSizeSpan(1.2f),0,17,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new RelativeSizeSpan(0.6f),18,37,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);mTextView.setText(span); – sowjanya Nov 05 '12 at 13:14