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);
这为我提供了整个TextView的普通文本。
谢谢。
答案 0 :(得分:0)
我们可以执行此功能
部分文字的字体
你必须使用alter net,比如取两个textview并划分文本并设置该文本。
或使用
spannable text
答案 1 :(得分:-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);