2014-03-14 30 views

回答

2

做類似下面,

String str="<small>Hello Stack</small><big>Over</big>flow"; 
textview.setText(Html.fromHtml(str)); 
+0

謝謝..它的工作 – user2799407

3

您可以使用SpannableString

例子:

TextView tv = new TextView(this); 
String string= "Hello"; 
String title="MyTitle"; 
SpannableString ss1= new SpannableString(string); 
ss1.setSpan(new RelativeSizeSpan(2f), 0, ss1.length(), 0); 
tv.append(ss1); 
tv.append(title); 
setContentView(tv); 

enter image description here

您還可以檢查

Using size HTML attribute in TextView

搜索支持的HTML標籤

http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

http://bigknol.com/android-supported-html-tags-textview-string/

0

您可以使用HTML字符串,使某些部分大膽例如

private String getHtmlText(String boldString,String restString){ 

    String htmlString = "<b>" +boldString +"</b> " + restString; 

    return htmlString; 
} 

,然後使用的setText Html.fromHtml(htmlString)像

yourTextView.setText(Html.fromHtml(getHtmlText(textBold,textNormal)));