android TextView underlining

  • 2020-05-19 05:44:27
  • OfStack

If you're in a resource file, write it like this.


< resources >   
    < string   name = "hello" > < u > phone: 1390123456 </ u > </ string >   
    < string   name = "app_name" > MyLink </ string >   
</ resources > 


 <resources>
    <string name="hello"><u>phone: 1390123456</u></string>
    <string name="app_name">MyLink</string>
</resources>

If you write it like this


TextView textView = (TextView)findViewById(R.id.testView);   
textView.setText(Html.fromHtml("<u>" + "hahaha" + "</u>" ));


Related articles: