Android 技術總結(018)—— ImageView動畫出現鋸齒問題

[java] 
/**
     * 生成縮放的動畫
     */ 
    private AnimationSet makeAnimation() { 
        // 創建復合動畫 
        AnimationSet animationSet = new AnimationSet(true); 
        // 創建ScaleAnimation對象 
        ScaleAnimation scaleAnimation = new ScaleAnimation(1, 0.1f, 1, 0.1f, 
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 
                0.5f); 
        scaleAnimation.setDuration(800); 
        animationSet.addAnimation(scaleAnimation); 
        // 創建TranslateAnimation對象 
        TranslateAnimation translateAnimation = new TranslateAnimation( 
                Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 
                (float) -(mScreenWidth * 0.14), Animation.ABSOLUTE, 0f, 
                Animation.ABSOLUTE, (float) (mScreenHeight / 1.56)); 
        translateAnimation.setDuration(800); 
        animationSet.addAnimation(translateAnimation); 
        // 設置插值器 
        animationSet.setInterpolator(new AccelerateInterpolator()); 
        return animationSet; 
    } 
[java] 
// 初始化動畫 
mShrinkAnimation = makeAnimation(); 
[java] 
// 開啟動畫 
mCutImage.setAnimation(mShrinkAnimation); 
mShrinkAnimation.start(); 
mShrinkAnimation.setAnimationListener(mShrinkAnimationListener); 
解決辦法:給ImageView設置padding值。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。