android字体闪烁动画(线程)
16lz
2021-12-04
android字体闪烁动画,使用线程和Timer实现
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);// 获取页面textview对象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.RED);} else {clo = 0;touchScreen.setTextColor(Color.GREEN);}}}});}};timer.schedule(taskcc, 1, 300); // 参数分别是delay(多长时间后执行),duration(执行间隔)}}
更多相关文章
- Android(安卓)ant 打包 ant -f build.xml release 出错
- ListView中使用线程实现无限加载
- android利用handler回到主线程
- android字体闪烁动画(线程)
- android(25)(android下实现多线程断点下载)
- 浅析Android中的消息机制
- 浅析Android中的消息机制
- 笔记:Android(安卓)Studio发布项目到Bintray
- Android(安卓)源码启动虚拟机经验