I use FloatLabel library (https://github.com/weddingparty/AndroidFloatLabel) to add a little animation when user begin to write something in an EditText Android
It may be late to answer this question but i have came across this problem. So thought to answer this. I have solved it by Implementing a CustomTextWatcher
.
Here is the snippet
private class CustomTextWatcher implements TextWatcher {
private EditText mEditText;
public CustomTextWatcher(EditText e) {
mEditText = e;
mEditText.setTypeface(Typeface.DEFAULT);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
mEditText.setTypeface(Typeface.DEFAULT);
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
mEditText.setTypeface(Typeface.MONOSPACE);
}
public void afterTextChanged(Editable s) {
if(s.length() <= 0){
mEditText.setTypeface(Typeface.DEFAULT);
} else {
mEditText.setTypeface(Typeface.MONOSPACE);
}
}
}
Here is how you can use it in your application
EditText pin = (EditText) findViewById(R.id.pin);
pin.addTextChangedListener(new CustomTextWatcher(pin));