How do you underline a text in Android XML?

前端 未结 10 982
不思量自难忘°
不思量自难忘° 2020-12-04 14:57

How do you underline a text in an XML file? I can\'t find an option in textStyle.

10条回答
  •  时光取名叫无心
    2020-12-04 15:46

    If you are using a string resource xml file (supports HTML tags), it can be done using , and .

    
        
            This is an underline.
        
    
    

    If you want to underline something from code use:

    TextView tv = (TextView) view.findViewById(R.id.tv);
    SpannableString content = new SpannableString("Content");
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    tv.setText(content);
    

    Hope this helps

提交回复
热议问题