• 利用代码定义动画


                  TextView tv = (TextView) findViewById(R.id.tv);
    
                    /**
                     * Scale动画
                     */
                    ScaleAnimation scaleAnim = new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                    scaleAnim.setDuration(700);
    
                    /**
                     * alpha动画
                     */
                    AlphaAnimation alphaAnim = new AlphaAnimation(1.0f, 0.1f);
                    alphaAnim.setDuration(3000);
                    alphaAnim.setFillBefore(true);
    
                    /**
                     * RotateAnimation
                     */
                    RotateAnimation rotateAnim = new RotateAnimation(0, -650, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                    rotateAnim.setDuration(3000);
                    rotateAnim.setFillAfter(true);
    
                    /**
                     * TranslateAnimation
                     */
                    TranslateAnimation translateAnim = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -80,
                            Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -80);
                    translateAnim.setDuration(2000);
                    translateAnim.setFillBefore(true);
    
    
                    /**
                     * AnimationSet
                     */
                    Animation alpha_Anim = new AlphaAnimation(1.0f, 0.1f);
                    Animation scale_Anim = new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                    Animation rotate_Anim = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    
                    AnimationSet setAnim = new AnimationSet(true);
                    setAnim.addAnimation(alpha_Anim);
                    setAnim.addAnimation(scale_Anim);
                    setAnim.addAnimation(rotate_Anim);
    
                    setAnim.setDuration(3000);
                    setAnim.setFillAfter(true);
    
    
                    tv.startAnimation(setAnim);

    动画监听:

        private void AnimationListener(final TextView tv) {
            RotateAnimation rotateAnim = new RotateAnimation(0, -650, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            rotateAnim.setDuration(3000);
            rotateAnim.setFillAfter(true);
    
    
            ScaleAnimation scaleAnim = new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            scaleAnim.setDuration(700);
            scaleAnim.setAnimationListener(new Animation.AnimationListener() {
                public void onAnimationStart(Animation animation) {
              //动画开始回调
                }
    
                public void onAnimationEnd(Animation animation) {
                    tv.startAnimation(rotateAnim);
             //动画结束回调
                }
    
                public void onAnimationRepeat(Animation animation) {
             //动画重复回调
                }
            });
    
            tv.startAnimation(scaleAnim);
    
        }
  • 相关阅读:
    photoshop--图像大小(分辨率和宽高)
    Arduino--单向倾斜开关
    禁止google浏览器http链接强制跳转为https
    属性缓存_使用ConcurrentDictionary替代Hashtable对多线程的对象缓存处理
    .Net(windows服务器)清理缓存数据的几个方法
    【西天取经】(升级.net5)用了一整天才把项目从.netcoreapp3.1升级到.net5(转载)
    在Debian 9 vim中启用鼠标复制粘贴
    将数据批量插入SQL Server
    shell 脚本中 在grep -E '($wo|$ni|$ta)' 这里面用变量
    kubernetes 重启的几种方法
  • 原文地址:https://www.cnblogs.com/loaderman/p/10194818.html
Copyright © 2020-2023  润新知