A TextView is displayed in one activity and the user goes to another activity to edit the properties of the text such as color, size, bold, italics, and underlined. When the user chooses to make the text bold, italic, or bold_italic it works. If the user unselects the checkbox the TextView does not return to normal. It can shift between the styles (ie if I check bold, then uncheck bold and check italic the TextView will be italic, not bold) but it cannot have a normal TypeFace.
I've searched around and everything I've found says that using the setTypeface method with Typeface.NORMAL should work but it is not working.
I would appreciate some help in solving this. The relevant code is below. Thank you!
TextView mDisplayMessage = (TextView) findViewById(R.id.message);
mDisplayMessage.setTypeface(mDisplayMessage.getTypeface(), Typeface.NORMAL);
//TODO: Cannot return all the way back to normal. Remains bold/italic/bold_italic
if (mIsBold && mIsItalic) mDisplayMessage.setTypeface(mDisplayMessage.getTypeface(), Typeface.BOLD_ITALIC);
else if (mIsBold) mDisplayMessage.setTypeface(mDisplayMessage.getTypeface(), Typeface.BOLD);
else if (mIsItalic) mDisplayMessage.setTypeface(mDisplayMessage.getTypeface(), Typeface.ITALIC);
else mDisplayMessage.setTypeface(mDisplayMessage.getTypeface(), Typeface.NORMAL);
if (mIsUnderlined) {
mDisplayMessage.setPaintFlags(mDisplayMessage.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
} else {
mDisplayMessage.setPaintFlags(0);
}
Try this,
mDisplayMessage.setTypeface(Typeface.DEFAULT);
OR
mDisplayMessage.setTypeface(null, Typeface.NORMAL);