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

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

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

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

// 按鈕模擬心臟跳動(dòng)
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);
        // 實(shí)現(xiàn)心跳的View
    imageView.startAnimation(animationSet);
   }
  });
    // 實(shí)現(xiàn)心跳的View
  imageView.startAnimation(animationSet);
}

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

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();

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

相關(guān)文章

最新評(píng)論

甘孜县| 沽源县| 团风县| 宝丰县| 泉州市| 浠水县| 泰兴市| 团风县| 鄂州市| 普格县| 泉州市| 楚雄市| 安溪县| 灵山县| 绥芬河市| 闽清县| 牟定县| 雷山县| 扎鲁特旗| 凤阳县| 陆良县| 竹溪县| 凤庆县| 巢湖市| 泗阳县| 射阳县| 福州市| 江都市| 伊金霍洛旗| 平遥县| 高雄市| 石阡县| 黔西县| 隆安县| 新化县| 彰化县| 芦溪县| 股票| 吴旗县| 宁远县| 元朗区|