ZabGo
11/30/2020, 5:27 PMpaswword.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun onTextChanged(p0: CharSequence?, start: Int, before: Int, count: Int) {}
override fun afterTextChanged(source: Editable?) {
val passwordDotDrawable = resources.getDrawable(R.drawable.password_dot)
passwordDotDrawable.setBounds(0, 0, 49, 49)
val spannableTag = Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
source?.forEachIndexed { index, char ->
val image = ImageSpan(passwordDotDrawable, ImageSpan.ALIGN_CENTER)
if (index < source.lastIndex) {
source.setSpan(image, index, index + 1, spannableTag)
} else if (index == source.lastIndex) {
CoroutineScope(Dispatchers.Main).launch {
delay(1000L)
source.setSpan(image, source.lastIndex, source.length, spannableTag)
}
}
}
}
})
Thank you in advance for your help