Is it possible to have multiple styles inside a TextView?

后端 未结 18 1852
醉梦人生
醉梦人生 2020-11-21 17:34

Is it possible to set multiple styles for different pieces of text inside a TextView?

For instance, I am setting the text as follows:

tv.setText(line         


        
18条回答
  •  悲&欢浪女
    2020-11-21 18:12

    In case, anyone is wondering how to do this, here's one way: (Thanks to Mark again!)

    mBox = new TextView(context);
    mBox.setText(Html.fromHtml("" + title + "" +  "
    " + "" + description + "" + "
    " + "" + DateAdded + ""));

    For an unofficial list of tags supported by this method, refer to this link or this question: Which HTML tags are supported by Android TextView?

提交回复
热议问题