// make the text twice as large
styledString.setSpan(
new
RelativeSizeSpan(2f),
0
,
5
,
0
);
// make text bold
styledString.setSpan(
new
StyleSpan(Typeface.BOLD),
7
,
11
,
0
);
// underline text
styledString.setSpan(
new
UnderlineSpan(),
13
,
23
,
0
);
// make text italic
styledString.setSpan(
new
StyleSpan(Typeface.ITALIC),
25
,
31
,
0
);
styledString.setSpan(
new
StrikethroughSpan(),
33
,
46
,
0
);
// change text color
styledString.setSpan(
new
ForegroundColorSpan(Color.GREEN),
48
,
55
,
0
);
// highlight text
styledString.setSpan(
new
BackgroundColorSpan(Color.CYAN),
57
,
68
,
0
);
// superscript
styledString.setSpan(
new
SuperscriptSpan(),
72
,
83
,
0
);
// make the superscript text smaller
styledString.setSpan(
new
RelativeSizeSpan(
0
.5f),
72
,
83
,
0
);
// subscript
styledString.setSpan(
new
SubscriptSpan(),
87
,
96
,
0
);
// make the subscript text smaller
styledString.setSpan(
new
RelativeSizeSpan(
0
.5f),
87
,
96
,
0
);
// url
// clickable text
ClickableSpan clickableSpan =
new
ClickableSpan() {
@Override
public
void
onClick(View widget) {
// We display a Toast. You could do anything you want here.
Toast.makeText(SpanExample.
this
,
"Clicked"
, Toast.LENGTH_SHORT).show();
}
};