i try to animate a TextView on a changeText
But always see only one direction of the animation, i only see the fadeout
What i try is: beforChange = fadeOut and onChange or after fadein
here is my code in the onCreate method of my activity:
final Animation out = new AlphaAnimation(1.0f, 0.0f);
out.setDuration(1000);
final Animation in = new AlphaAnimation(0.0f, 1.0f);
in.setDuration(1000);
bidFirst.setAnimation(out);
bidMiddle.setAnimation(out);
bidLast.setAnimation(out);
TextWatcher bidWatcher = new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
in.startNow();
bidFirst.setAnimation(out);
bidMiddle.setAnimation(out);
bidLast.setAnimation(out);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
out.startNow();
bidFirst.setAnimation(in);
bidMiddle.setAnimation(in);
bidLast.setAnimation(in);
}
public void afterTextChanged(Editable s) {
}
};
bidFirst.addTextChangedListener(bidWatcher);
bidMiddle.addTextChangedListener(bidWatcher);
bidLast.addTextChangedListener(bidWatcher);
i think there is something wrong in my code but for my believe it has to work.
What i have now is: on every setText the changed Text only FadeOut but after the text has changed and never FadeIn!?
TextSwitcher is exactly what you are looking for. Just use their
setInAnimation()andsetOutAnimation. Than the animations will run automatically if you change the text bysetText()