有没有人知道如何从EditText获取spannable的TypeFace。
我有一个EditText:
// Instantiate EditText noteContent//
noteContent = (EditText) findViewById(R.id.noteContent);
noteContent.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
我有一个spannable:
if (id == R.id.italic) {
int startSelection = noteContent.getSelectionStart();
int endSelection = noteContent.getSelectionEnd();
Spannable spannable = noteContent.getText();
Typeface style = noteContent.getTypeface();
if (style.equals(Typeface.defaultFromStyle(Typeface.ITALIC))) {
spannable.setSpan(new StyleSpan(Typeface.ITALIC), startSelection, endSelection , 0);
} else {
StyleSpanRemover spanRemover = new StyleSpanRemover();
spanRemover.RemoveStyle(spannable, startSelection, endSelection, Typeface.ITALIC);
}
}
如果statment获得整个edittext的字体而不仅仅是spannable,问题是这个。如何获得spannable的当前字体?