val readNametextWatcher = object : TextWatcher {
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
count: Int,
after: Int
) {
}
override fun onTextChanged(
s: CharSequence?,
start: Int,
before: Int,
count: Int
) {
if (count == 0) {
edRealName.setCompoundDrawablesRelative(null, null, null, null);
} else {
var drawable =
this@FaceAuthenticationActivity.resources.getDrawable(R.mipmap.ic_real_name_delete);
// <span style="color:#ff0000;">// 在 setCompoundDrawablesRelative 之前一定要对 Drawable 进行设置,不然没有效果</span>
if (drawable != null) {
drawable.setBounds(
0,
0,
drawable.getMinimumWidth(),
drawable.getMinimumHeight()
);
}
edRealName.setCompoundDrawablesRelative(null, null, drawable, null);
}
}
override fun afterTextChanged(s: Editable?) {
}
}