Android动画

帧动画FrameAnimation

  • 多张图片快速切换,形成动画效果
  • 帧动画使用xml定义

补间动画

  • 组件由原始状态向终极状态转变时,为了让过渡更自然,而自动生成的动画

位移动画

    TranslateAnimation ta = new TranslateAnimation(10, 100, 20, 200);

* 10:表示的x坐标起始位置
* iv的真实x + 10

  • 100:表示x坐标的结束位置

    • iv的真实x + 100
  • 20:表示y坐标的起始位置

    • iv的真实y + 20
  • 200:表示y坐标的结束位置

    • iv的真实y + 200

      TranslateAnimation ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 3, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 2);
      
  • Animation.RELATIVE_TO_SELF, 1:x坐标的初始位置

    • iv的真实x + 1 * iv宽
  • Animation.RELATIVE_TO_SELF, 0.5f:y坐标的起始位置

    • iv的真实y + 0.5 * iv高

缩放动画

    ScaleAnimation sa = new ScaleAnimation(0.5f, 2, 0.1f, 3, iv.getWidth() / 2, iv.getHeight() / 2);

* 0.5f:表示x坐标缩放的初始位置
* 0.5 * iv宽
* 2:表示x坐标缩放的结束位置
* 2 * iv宽
* iv.getWidth() / 2:表示缩放点的x坐标
* iv的真实x + iv.getWidth() / 2

        ScaleAnimation sa = new ScaleAnimation(0.5f, 2, 0.1f, 3, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

* Animation.RELATIVE_TO_SELF, 0.5f:表示缩放点的x坐标
* iv的真实x + 0.5 * iv宽

透明动画

    AlphaAnimation aa = new AlphaAnimation(0, 0.5f);

* 0表示动画的起始透明度
* 0.5f表示动画的结束透明度

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值