android中Tween动画的监听事件【实现小球在手机屏幕运动一圈】
来源:互联网 发布:淘宝开店上传宝贝技巧 编辑:程序博客网 时间:2024/05/29 06:34
width是手机的宽度;height是手机的高度;
pop_iv是小球球图片;
iv_width是小球的宽度;iv_heigt是晓求得高度;
主要:在每一个动画监听事件的结束方法里写下一个动画,只能点击按钮转一圈,重复旋转这里么有实现;
if(){}的判断根据自己的要求去改
遇到的问题:
昨天用Tween实现了小球转圈运动,但是在该页面没有重启的时候,小球只保存最后一次if判断的动画效果
TranslateAnimation animation = new TranslateAnimation(0, 0, 0, height - iv_height);animation.setDuration(1000);animation.setFillAfter(true);//动画的监听事件animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { // float x = pop_iv.getX(); float x = pop_iv.getRotationX(); float y = pop_iv.getY(); System.out.println("animation===x的值是:" + x + "+y的值是:" + y); } @Override public void onAnimationEnd(Animation animation) { if (height - iv_height > 500) { final TranslateAnimation ani = new TranslateAnimation(0, width - 82, height - iv_height, height - iv_height); ani.setDuration(1000); ani.setFillAfter(true); ani.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { float x = pop_iv.getX(); float y = pop_iv.getY(); System.out.println("ani==x的值是:" + x + "+y的值是:" + y); } @Override public void onAnimationEnd(Animation animation) { if (width - iv_width > 200) { TranslateAnimation ani1 = new TranslateAnimation(width - 82, width - 82, height - iv_height, 0); ani1.setDuration(1000); ani1.setFillAfter(true); ani1.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { float x = pop_iv.getX(); float y = pop_iv.getY(); System.out.println("ani1==x的值是:" + x + "+y的值是:" + y); } @Override public void onAnimationEnd(Animation animation) { // if ((width - iv_width == 82)) { TranslateAnimation ani2 = new TranslateAnimation(width - 82, 0, 0, 0); ani2.setDuration(1000); ani2.setFillAfter(true); ani2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { float x = pop_iv.getX(); float y = pop_iv.getY(); System.out.println("ani2==x的值是:" + x + "+y的值是:" + y); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) {animation.setRepeatCount(-1);} }); pop_iv.startAnimation(ani2); } // } @Override public void onAnimationRepeat(Animation animation) {animation.setRepeatCount(-1);} }); pop_iv.startAnimation(ani1); } } @Override public void onAnimationRepeat(Animation animation) {animation.setRepeatCount(-1);} }); pop_iv.startAnimation(ani); } } @Override public void onAnimationRepeat(Animation animation) {animation.setRepeatCount(-1);}});pop_iv.startAnimation(animation);
0 0
- android中Tween动画的监听事件【实现小球在手机屏幕运动一圈】
- 在 egret 中 利用 tween 实现 二次贝塞尔运动
- Android的Tween动画的实现框架
- Android的Tween动画的实现框架
- Android的Tween动画的实现框架
- android补间动画(Tween)的实现
- Android实现小球一直运动
- Tween动画的实现
- 【Android 基础】Animation 动画介绍和实现【帧动画和Tween动画【在代码和xml中实现】】
- Promise实现小球的运动
- android的tween动画在动画结束后停止
- android动画模块 Tween 动画的实现原理 详解
- AndroidのTween动画实现
- Android --- Tween动画示例(代码中定义的动画)
- android中tween动画自定义
- android动画-tween动画实现原理
- Android动画之Tween动画实现
- android 动画实现(一)Tween动画
- 大小端判断
- CSS知识整理
- appche kudu 安装简单步骤
- aliyun服务器ecs被ddos后无法被zabbix-server监控的处理
- nrf51822裸机教程-RTC
- android中Tween动画的监听事件【实现小球在手机屏幕运动一圈】
- FFmpeg source demo 在VS2010下错误总结
- 蓝鸥iOS从零基础到精通就业-OC语言入门 对象内存管理2
- Java三大框架
- 第一天学习php 2016年12月29日
- 安卓常用自定义View
- [python] 基于k-means和tfidf的文本聚类代码简单实现
- TCP与UDP的区别
- BitmapShader