This article is an example of how Android implements font flicker animation. Share to everyone for your reference. Specifically as follows:
This is based on the thread and timer to achieve the Android font flashing animation effect.
?
public class Activitymain extends activity {
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
Spark ();
}
private int clo = 0;
public void Spark () {
Final TextView touchscreen = (TextView) Findviewbyid (R.ID.TEXTVIEW01);//Get Page TextView Object
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); Transparent
} else {
if (Clo = = 1) {
CLO = 2;
Touchscreen.settextcolor (color.red);
} else {
CLO = 0;
Touchscreen.settextcolor (Color.green);
}
}
}
});
}
};
Timer.schedule (TASKCC, 1, 300);
Parameters are delay (how long after execution), duration (execution interval)
}
}
I hope this article will help you with your Android program.