现在我有了这段代码:
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"
。我怎么能这样做?
答案 0 :(得分:5)
我不知道使用标记<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);