1

现在我有这个代码:

TextView textView = (TextView) convertView.findViewById(R.id.label);
String html = name + " - <small>" + description + "</small>";
textView.setText(Html.fromHtml(html));

textView 在哪里有android:textAppearance="?android:attr/textAppearanceLarge". 但我需要的是<small>放置 textApparence的实例android:textAppearance="?android:attr/textAppearanceSmall"。我怎样才能做到这一点?

4

1 回答 1

8

我不知道使用 tag <small>,但您可以使用它来覆盖部分文本的样式:

SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append("name - ");
int start = sb.length();
sb.append("description");
sb.setSpan(new TextAppearanceSpan(this, android.R.style.TextAppearance_Small), start, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sb.append(" - ");
myText.setText(sb);
于 2011-08-26T11:56:52.787 回答