Toolbar title first letter different color

I want my toolbar to have a colored title. It's not a problem. But how can I achieve this first letter of the tile for example. black and the rest are white? Is it possible?

+3


source to share


2 answers


Can be used Html.fromHtml

to change the font color for two parts of a line. For example.



String first = "<font color='#FF000000'>F</font>";
String rest = "<font color='#FFFFFFFF'>irst</font>";
setTitle(Html.fromHtml(first + rest));

      

+3


source


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);

      

+3


source







All Articles