This question already has answers here:
How to display HTML in TextView?
                                
                                    (22个答案)
                                
                        
                                去年关闭。
            
                    
为什么文字不像我写的那样粗体和斜体?
这是我的值字符串xml代码:

 <string name="fragrance"> <b>FirstItem</b> \n<i>Description</i> </string>


android - 为什么文本不显示为我在xml中编写的?-LMLPHP

最佳答案

您必须通过以下方式进行设置:

Spanned htmlString = Html.fromHtml(getString(R.string.fragrance));
textView.setText(htmlString);

08-06 08:34