android裏TextView加下劃線的幾種方式

若是是在資源文件裏:app

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

 

若是是代碼裏:spa

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

代碼也能夠這樣:code

tvTest.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下劃線tvTest.getPaint().setAntiAlias(true);//抗鋸齒
相關文章
相關標籤/搜索