现在的位置: 首页 > 综合 > 正文

文字闪烁效果

2017年04月10日 ⁄ 综合 ⁄ 共 525字 ⁄ 字号 评论关闭
源:http://blog.csdn.net/imdxt1986/article/details/6790261

private int clo = 0;

	public void spark(int id) {
		final TextView touchScreen = (TextView) findViewById(id);// 获取页面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(执行间隔)

	}

抱歉!评论已关闭.