android textview 特出显示

在xml文件中使用android:textStyle="bold" 可以将英文设置成粗体,但是不能将中文设置成粗体,将中文设置成粗体的方法是: 
TextView tv = (TextView)findViewById(R.id.TextView01); 
TextPaint tp = tv.getPaint(); 
tp.setFakeBoldText(true); 
其他还有: 
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//设置成24sp  
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//可能中文加粗无效 
textView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));//可能中文无效 
textView.setText(Html.fromHtml("<u>"+texts+"</u>"));//下划线 
textView.setTypeface(Typeface.MONOSPACE,Typeface.ITALIC);//斜体,中文有效 
textView.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );//中间加横线 
textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );//底部加横线

 

 

promotionLinkText = (TextView) this .findViewById(R.id. text_promotion_link ); 
中间加横线 
promotionLinkText .getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG ); 
底部加横线: 
promotionLinkText .getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );

猜你喜欢

转载自niufc.iteye.com/blog/1851599