本文实例讲述了android实现字体闪烁动画的方法。分享给大家供大家参考。具体如下:

这里基于线程和Timer实现Android的字体闪烁动画效果。

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程序设计有所帮助。

更多相关文章

  1. 创建android逐帧动画的两种方式
  2. android dialog 动画
  3. Android修改字体样式
  4. Android模仿微信、云播雷达扫描动画效果
  5. android 4.0动画学习
  6. Android动画效果——X、Y轴抖动
  7. android中动画效果的运用

随机推荐

  1. 使用VirtualBox在PC上安装Android OS
  2. Android学习感想一
  3. Android开发学习笔记:Android很有用的代码
  4. 【Qt for Android】第一个安卓程序
  5. Android启动过程——init,Zygote,SystemS
  6. Android 下led 的控制(上)--Android部分
  7. android添加新驱动
  8. 实现调用android URLConnection封装后快
  9. android 核心组件( 1 ) 常用布局, adapte
  10. Android中利用GridView实现水平和垂直均