Text view with different colored texts in xml code

后端 未结 4 1673
情歌与酒
情歌与酒 2020-12-16 16:41

I need my textview to have different colored texts. Also I need to do this from xml code, non from java code. Is there anyone who knows some way fo

4条回答
  •  长情又很酷
    2020-12-16 17:09

    Refer your text to string.xml and using html font tag , by using that way you can change each letter color also .

    just add this in java for that string:

      TextView tv=(TextView)findViewById(R.id.tv);
    
      tv.setText(Html.fromHtml(getString(R.string.any_text)));
    

    and

    In string.xml:

     
     write your text here .
    
    ]]> 
      
    

    hope help you

提交回复
热议问题