Tried through Html.fromHtml , but does not work. Probably because the project uses a third-party font. I was looking for an answer on this site, but there is a suggestion just how to make a capital letter.

  • In addition to SpannableString, you can use fonts, for the assets / fonts folder, to make the first letter even cooler, the type as in the books there is the first letter on the floor of the page. And if dynamically, then most likely two concatenated strings will be transferred to TextView, one contains a large letter, the second a text (if the first one is filled). - Oleg Kotenko

2 answers 2

 SpannableStringBuilder ssb = new SpannableStringBuilder(text); StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); if(text.length()>0) ssb.setSpan(boldSpan, 0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE); textView.setText(ssb); 
  • Exactly what is needed. Thank. - SET1

In the resource file wrap the desired letter tag <b></b>

res / values ​​/ strings.xml

 <resources> <string name="my_text"><b>H</b>ello World!</string> </resources> 

res / layaout / activity_main.xml

 <TextView android:text="@string/my_text" android:textSize="22sp" android:padding="5dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView1"/> 
  • Thank. Is there an option how to do this with code? It just may happen that the string will be dynamic and this option will not work. - SET1