Remove Bold from textview without changing other attributes
just create a new Typeface can make bold
back to normal
tv.setTypeface(Typeface.create(tv.getTypeface(), Typeface.NORMAL), Typeface.NORMAL);
tv.invalidate();
this chunk of code removed the old Typeface setTypeface(null,Typeface.NORMAL);
For keeping the old you should call
setTextViewStyle(textView, isBold);
private void setTextViewStyle(TextView view, boolean isBold){
if (view == null)
return;
// if old typeface is null create new Typeface bold or def
Typeface oldTypeface = view.getTypeface() != null ? view.getTypeface() :
(isBold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
view.setTypeface(
Typeface.create(oldTypeface, isBold ? Typeface.BOLD : Typeface.NORMAL)
);
}
tv.setTypeface(null,Typeface.NORMAL);
This would set the style back to normal without changing color or size.
But you can't mix bold/italic/underline text this way. If you specify BOLD, all of the text will be bold. If you want to mix the style of the text I suggest using HTML to style the text, and then use the following code.
tv.setText(Html.fromHtml(yourStringAsHtml));