最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android編程實現(xiàn)仿心跳動畫效果的方法

 更新時間:2015年11月19日 14:35:12   作者:lee0oo0  
這篇文章主要介紹了Android編程實現(xiàn)仿心跳動畫效果的方法,實例分析了Android基于線程實現(xiàn)動畫過度效果的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了Android編程實現(xiàn)仿心跳動畫效果的方法。分享給大家供大家參考,具體如下:

// 按鈕模擬心臟跳動
private void playHeartbeatAnimation() {
  AnimationSet animationSet = new AnimationSet(true);
  animationSet.addAnimation(new ScaleAnimation(1.0f, 1.8f, 1.0f, 1.8f,
    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
    0.5f));
  animationSet.addAnimation(new AlphaAnimation(1.0f, 0.4f));
  animationSet.setDuration(200);
  animationSet.setInterpolator(new AccelerateInterpolator());
  animationSet.setFillAfter(true);
  animationSet.setAnimationListener(new AnimationListener() {
   @Override
   public void onAnimationStart(Animation animation) {
   }
   @Override
   public void onAnimationRepeat(Animation animation) {
   }
   @Override
   public void onAnimationEnd(Animation animation) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.8f, 1.0f, 1.8f,
      1.0f, Animation.RELATIVE_TO_SELF, 0.5f,
      Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(0.4f, 1.0f));
    animationSet.setDuration(600);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(false);
        // 實現(xiàn)心跳的View
    imageView.startAnimation(animationSet);
   }
  });
    // 實現(xiàn)心跳的View
  imageView.startAnimation(animationSet);
}

由于這是一個循環(huán)的動畫,所以需要開一個線程來進(jìn)行動畫的實現(xiàn),當(dāng)然還有另外一個方法,就是在一個動畫結(jié)束開始另一個動畫,在另一個動畫結(jié)束開始這個動畫也可以,這邊示例用的是線程。

new Thread(){
 public void run() {
  while (true){
   try {
    Thread.sleep(1000);
   } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
   runOnUiThread(new Runnable() {
    public void run() {
     playHeartbeatAnimation();
    }
   });
  }
 };
}.start();

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論

垣曲县| 龙门县| 黎平县| 海安县| 仙游县| 吉首市| 万山特区| 阿图什市| 临汾市| 沙河市| 清徐县| 紫阳县| 什邡市| 沙河市| 平定县| 北安市| 宁国市| 南康市| 西乡县| 高陵县| 伊金霍洛旗| 麻栗坡县| 台州市| 德安县| 仁布县| 华容县| 塔河县| 康定县| 长沙市| 都昌县| 汝南县| 筠连县| 山东| 齐河县| 浑源县| 松江区| 海门市| 中卫市| 仁化县| 扶沟县| 本溪市|