You must add a TextWatcher to the EditText. This will notify you when the text changes.
When you know that the text has changed, you can run it through DecimalFormat:
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setDecimalSeparatorAlwaysShown(true);
decimalFormat.setMaximumFractionDigits(2);
source
share