我尝试在 changeText 上为 TextView 设置动画但总是只看到动画的一个方向,我只看到淡出
我尝试的是:beforChange = fadeOut and onChange or after fadein
这是我活动的 onCreate 方法中的代码:
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);
我认为我的代码有问题,但我相信它必须起作用。
我现在拥有的是:在每个 setText 上,更改的文本仅 FadeOut,但在文本更改之后,从不 FadeIn!?