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.
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
sowjanya
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);
来源:https://stackoverflow.com/questions/13227670/using-custom-font-for-part-of-a-text