代码动画编写

本文详细介绍了如何通过各种工具和库来创建引人入胜的代码动画,包括使用JavaScript库如D3.js,以及Python的matplotlib等。内容涵盖从基本概念到高级技巧,帮助开发者将代码过程可视化,提升教学或演示效果。
摘要由CSDN通过智能技术生成

 

private void startCodeAnim(){
		AnimationSet animationSet = new AnimationSet(true);
//		AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
//		alphaAnimation.setDuration(1000);
//		alphaAnimation.setStartOffset(10000);
		//scale缩放比从2倍到1(原始大小)
		ScaleAnimation scale = new ScaleAnimation(2.0f, 1.0f, 2.0f, 1.0f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
		scale.setDuration(1000);//动画播放间隔
		animationSet.addAnimation(scale);
		//rotate反方向旋转20度
		RotateAnimation rotate =new RotateAnimation(0f,-20f,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,0.5f); 
		rotate.setDuration(1000);
		animationSet.addAnimation(rotate);
		//translate从原始位置向x和y的正方向移动原始图片大小的10%距离
		TranslateAnimation translate = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0.1f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0.1f);
		translate.setDuration(1300);
		animationSet.addAnimation(translate);
		//animationSet.setStartOffset(10000);
//		animationSet.setFillBefore(false);
		//设置不动画播放完后不回到原始位置
		animationSet.setFillAfter(true);
		//添加并播放动画
		iv1.startAnimation(animationSet);
	}


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值