Android 圖片自動放大/縮小循環執行

    private void addAnimation(){
        img_show.startAnimation(scaleAnimation());				
       // img_show.clearAnimation(); //停止動畫
    }
    /**
     * 圖片自動循環縮放
     * @return
     */
    public static ScaleAnimation scaleAnimation() {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.5f, 1.0f, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

        scaleAnimation.setDuration(900);                        //動畫執行時間
        scaleAnimation.setRepeatCount(-1);                    //-1表示重複執行動畫
        scaleAnimation.setRepeatMode(Animation.REVERSE);    //重複 縮小和放大效果
        return scaleAnimation;
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章