Afdal Dev :
Vishist Varugeese :
You can use TextWatcher
for this and setBackgroundTintList
to change the line color,
et.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s != null && !(s.toString().isEmpty())) {
//Color when text exists
ColorStateList colorStateList = ColorStateList.valueOf(getResources().getColor(R.color.colorPrimaryDark));
ViewCompat.setBackgroundTintList(et, colorStateList);
} else {
//Default color - color when text does not exist
ColorStateList colorStateList = ColorStateList.valueOf(getResources().getColor(R.color.colorAccent));
ViewCompat.setBackgroundTintList(et, colorStateList);
}
}
@Override
public void afterTextChanged(Editable s) {}
});
Please refer to this link.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=350450&siteId=1