如何逐个字母显示textview?
我想给每个字母一个动画。
我尝试过的代码。
public void setText(final String s)
{
final TextView tv= (TextView)findViewById(R.id.txt1);
final AlphaAnimation animation = new AlphaAnimation(0.0f,1.0f);
animation.setDuration(1500);
final int[] i = new int[1];
i[0] = 0;
final int length = s.length();
final Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
char c= s.charAt(i[0]);
Log.d("Strange",""+c);
tv.append(String.valueOf(c));
tv.setAnimation(animation);
i[0]++;
}
};
final Timer timer = new Timer();
TimerTask taskEverySplitSecond = new TimerTask() {
@Override
public void run() {
handler.sendEmptyMessage(0);
if (i[0] == length - 1) {
timer.cancel();
}
}
};
timer.schedule(taskEverySplitSecond, 1, 2000);
}
我不知道动画代码的正确位置。