Android中的AnimationSet使用
来源:互联网 发布:java程序员工资一般多少 编辑:程序博客网 时间:2024/05/13 20:25
AnimatorSet:这个类为一组特定的动画指定次序。
总要办法如下:
play:该办法创建一个机关器对象用于创建束缚。
playTogether:设置同时运行一组动画
pase:暂停一个正在运行的动画
resume:从头运行暂停后的动画
isRunning:断定动画是否正在运行
isStarted:断定动画是否已经运行了
话不多说,直接上图:
这个场景其实就是一个用户的头像选择,最中间的为用户默认的头像,点击四周头像可以与中间的头像进行交换。交换的过程就是用到了Android动画中AnimationSet这个类。
onClick事件具体执行内容:
private void switchImage(ImageView image){if(!animSet.isStarted() && image.getId()!=img_center.getId()){ //判断动画是否在运行,并且点击图片若在中间则不交换ObjectAnimator anim1, anim2, anim3, anim4, anim5, anim6, anim7, anim8, anim21, anim61;animSet = new AnimatorSet();anim1 = ObjectAnimator.ofFloat(image, "alpha",0.2f, 1f);anim2 = ObjectAnimator.ofFloat(image,"y", image.getY() , img_center.getY());anim21 = ObjectAnimator.ofFloat(image,"x", image.getX() , img_center.getX());anim3 = ObjectAnimator.ofFloat(image, "scaleX",1.0f, 1.2f);anim4 = ObjectAnimator.ofFloat(image, "scaleY",1.0f, 1.2f);anim5 = ObjectAnimator.ofFloat(img_center, "alpha",1f, 0.2f);anim6 = ObjectAnimator.ofFloat(img_center,"y", img_center.getY() , image.getY());anim61 = ObjectAnimator.ofFloat(img_center,"x", img_center.getX() , image.getX());anim7 = ObjectAnimator.ofFloat(img_center, "scaleX",1f, 0.8f);anim8 = ObjectAnimator.ofFloat(img_center, "scaleY",1f, 0.8f);animSet.play(anim1).with(anim2).with(anim3).with(anim4).with(anim5).with(anim6).with(anim7).with(anim8).with(anim21).with(anim61);animSet.setDuration(1000);animSet.start();imgs.put(img_center, imgs.get(image));imgs.put(image, 22);image.setPadding(15,15,15,15);img_center.setPadding(0,0,0,0);img_center = image;System.out.println("center_id:"+img_center.getId());}}
0 0
- Android中的AnimationSet使用
- Android中的AnimationSet使用
- Android中的AnimationSet使用
- Android中的AnimationSet使用
- android AnimationSet 使用
- android AnimationSet
- android animationset
- Android 动画类AnimationSet的使用
- Android 动画 - AnimationSet 动画集合使用(附图)
- android AnimationSet小结
- android:interpolator animationSet属性
- Android之AnimationSet
- Android AnimationSet详解
- AnimationSet
- AnimationSet
- AnimationSet
- AnimationSet
- .X文件中的AnimationSet分析
- 重拾Java回忆录(五):Java05接口的使用
- Firefox 弹出窗口不让显示地址栏设置.
- iOS UITableView实现滑动删除、增加、多选
- springMVC如何跨域请求-jsonp
- 模板的分离编译
- Android中的AnimationSet使用
- 高手教你如何在Dreamweaver中编写CSS
- shuffle vector
- leetcode——Largest Number
- online_judge_1045
- php中的输出缓冲区ob_flush
- Hibernate级联关系OneToMany之XXX.hbm.xm实现
- JVM中各内存区域解释,以及变量的作用域解释
- JAVA对String的分割操作 ---- 几室几厅