Reputation: 993
I want my toolbar to have a colored title. That's not the problem. But how can I achieve that the first letter of the tile e.g. is black and the rest white? Is this possible?
Upvotes: 3
Views: 77
Reputation: 1229
Use SpannableString
SpannableString title = new SpannableString("Title text");
title.setSpan(new ForegroundColorSpan(Color.BLACK), 0, 1, 0);
title.setSpan(new ForegroundColorSpan(Color.WHITE), 1, title.length(), 0);
setTitle(title);
Upvotes: 3
Reputation: 157467
One one could be to use Html.fromHtml
to change the font's color of the two part of the String. E.g.
String first = "<font color='#FF000000'>F</font>";
String rest = "<font color='#FFFFFFFF'>irst</font>";
setTitle(Html.fromHtml(first + rest));
Upvotes: 3