I have an EditText View which is being used to make users enter a text. After certain characters, I want to reduce the Font Size of the Text within the EditText. I am using the TextWatcher's
onTextChanged
listener to track the user input and the length of the characters. This part is working as expected. But to set the Font size of the text I am using the below approach:
final Spannable span = new SpannableString(editText.getText());
span.setSpan(new RelativeSizeSpan(0.9f), 0, string.length), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
editText.setText(span);
Now, I am facing two problems:
For eg., if the current text is "ABC" and then the font size of this text is updated then if a user enters "123" in front of "ABC" like "123ABC" the size of 123 is not the same as updated text size but is the same as the original font size but the "ABC" continues to remain the updated desired font size.
Any help would be appreciated.
Thanks.
Check this Truss.java, Easy to implement and can solve lot of the issues we face related to SpannableString