当前位置:操作系统 > 安卓/Android >>

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值。
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,