0

I wanted to make my hint to not animate if the edit text is empty. If user start typing the hint will move up, but if the edit text is empty, the hint will return into the edit text.

I have tried

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                if(s.length() == 0){
                    textInputLayout4.setHintAnimationEnabled(false);
                } else {
                    textInputLayout4.setHintAnimationEnabled(true);
                }
            }

but the hint does not act like how I wanted it to be.

yuzuriha
  • 465
  • 1
  • 8
  • 18

1 Answers1

1

Instead of beforeTextChanged(), try using afterTextChanged():

@Override
public void afterTextChanged(Editable s) {
                if(s.toString().isEmpty()){
                    textInputLayout4.setHintAnimationEnabled(false);
                } else {
                    textInputLayout4.setHintAnimationEnabled(true);
                }
            }
Sonam
  • 572
  • 4
  • 13
  • After I tried this and few research, I found that I have you use textInputLayout4.setHintEnabled(true / false); but then I lost the animation.. tried to put the textInputLayout4.setHintAnimationEnabled(true); but still no animation – yuzuriha May 30 '17 at 01:55