Android自定义控件开发入门与实战(4)属性动画,移动开发技术

本文介绍了Android自定义控件开发中的属性动画,通过代码展示了如何使用doAnimationClose方法进行动画效果,讲解了Animator的XML实现,包括animator、objectAnimator和set标签,并探讨了PropertyValuesHolder、KeyFrame在动画中的应用,以及自定义动画速率变化的方法。
摘要由CSDN通过智能技术生成

doAnimationClose(mItemButton1, 0, 5, 300);

doAnimationClose(mItemButton2, 1, 5, 300);

doAnimationClose(mItemButton3, 2, 5, 300);

doAnimationClose(mItemButton4, 3, 5, 300);

doAnimationClose(mItemButton5, 4, 5, 300);

}

private void doAnimationClose(View v, int index, int total, int radius) {

if (v.getVisibility() != View.VISIBLE) {

v.setVisibility(View.VISIBLE);

}

double degree = Math.PI * index / ((total - 1) * 2);

int translationX = (int) -(radius * Math.sin(degree));

int translationY = (int) -(radius * Math.cos(degree));

AnimatorSet set = new AnimatorSet();

set.playTogether(ObjectAnimator.ofFloat(v, “translationX”, translationX, 0),

ObjectAnimator.ofFloat(v, “translationY”, translationY, 0),

ObjectAnimator.ofFloat(v, “scaleX”, 1f, 0f),

ObjectAnimator.ofFloat(v, “scaleY”, 1f, 0f),

ObjectAnimator.ofFloat(v,

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值