Вот код, который я использовал, на случай, если он кому-то поможет
class DecimalFormatter(private val txt: EditText): TextWatcher {
var ignoreChanges = false
override fun afterTextChanged(s: Editable?) {
if (!ignoreChanges) {
ignoreChanges = true
var content = txt.text.toString().replace(".", ",")
var newContent = ""
var commaFound = false
for (c: Char in content) {
if ((c == ',' && !commaFound) || c != ',') {
newContent += c
if (c == ',') {
commaFound = true
}
}
}
txt.setText(newContent)
if (newContent == "") {
newContent = "0,0"
}
txt.setSelection(txt.text.length)
ignoreChanges = false
}
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
}