package com.android.WordAnimation;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;
public class WordAnimationActivity extends Activity {
private int clo = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
spark();
}
public void spark() {
final TextView touchScreen = (TextView)findViewById(R.id.TextView01);
Timer timer = new Timer();
TimerTask taskcc = new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if (clo == 0) {
clo = 1;
touchScreen.setTextColor(Color.TRANSPARENT);
} else {
if (clo == 1) {
clo = 2;
touchScreen.setTextColor(Color.YELLOW);
} else if (clo == 2){
clo = 3;
touchScreen.setTextColor(Color.RED);
} else {
clo = 0;
touchScreen.setTextColor(Color.BLUE);
}
}
}
});
}
};
timer.schedule(taskcc, 1, 100);
}
}
android的字体闪烁效果,
timer.schedule(taskcc, 1, 100);
其中的参数是:
第二个参数分别是delay(多长时间后执行),第三个参数是:duration(执行间隔)单位为:ms