版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Rexsee API介绍:Animations动画学习笔记及源码在Android上实现动画,官方的SDK提供了Animations,并且介绍了两种不同模式,分别是:1. Tween Animation:通过对场景里的对象不断做图像变换(平移、缩放、旋转)产生动画效果,即是一种渐变动画;2. Frame Animation:顺序播放事先做好的图像,是一种画面转换动画。同时,Animation由四种类型组成:XML文件: alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果在Java 源码中定义了相应的类
2、,可以使用这些类的方法来获取和操作相应的属性: AlphaAnimation 渐变透明度动画效果 ScaleAnimation 渐变尺寸伸缩动画效果 TranslateAnimation 画面转换位置移动动画效果 RotateAnimation 画面转移旋转动画效果具体Android的原生就不再多说了,相对复杂,有兴趣的可以直接去看google的SDK。这里分享了Rexsee的API,基于对原生的封装,可以直接使用JS实现功能调用。如:【事件】 void onAnimationStart(String id)【说明】 当动画开始播放时触发。在Rexsee社区可以直接查看源码。同时,新上线的项目
3、中心提供了在线开发服务,不需要单独准备服务器。同时也有大量的应用以分享的方式开放供查阅,关于动画的具体应用源码也可以在这里查到:/project/Rexsee API:Animations源码Java代码1 packagerexsee.core.animation;23 importrexsee.core.style.StyleSheet;4 importrexsee.core.utilities.RexseeUtilities;5 importandroid.view.View;6 importandroid.view.animation.Accele
4、rateDecelerateInterpolator;7 importandroid.view.animation.AccelerateInterpolator;8 importandroid.view.animation.AlphaAnimation;9 importandroid.view.animation.Animation;10 importandroid.view.animation.AnimationSet;11 importandroid.view.animation.AnticipateInterpolator;12 importandroid.view.animation.
5、AnticipateOvershootInterpolator;13 importandroid.view.animation.BounceInterpolator;14 importandroid.view.animation.CycleInterpolator;15 importandroid.view.animation.DecelerateInterpolator;16 importandroid.view.animation.Interpolator;17 importandroid.view.animation.LinearInterpolator;18 importandroid
6、.view.animation.OvershootInterpolator;19 importandroid.view.animation.RotateAnimation;20 importandroid.view.animation.ScaleAnimation;21 importandroid.view.animation.TranslateAnimation;2223 publicclassAnimationsextendsAnimation2425 publicAnimations()26 super();27 2829 publicstaticAnimationgetAnimatio
7、n(StyleSheetstyle,AnimationListenerlistener,Viewview,ViewviewParent)30 if(view=null)returnnull;31 if(viewParent=null)32 try33 viewParent=(View)view.getParent();34 catch(Exceptione)35 viewParent=view;36 37 38 AnimationSetanimation=newAnimationSet(true);39 Stringtypes=style.animation_type.split(+);40
8、intlength=0;41 animation.setDuration(Integer.parseInt(style.animation_rotate_duration);42 animation.setRepeatCount(Integer.parseInt(style.animation_rotate_repeat_count);43 animation.setRepeatMode(style.animation_rotate_repeat_mode.equalsIgnoreCase(normal)?1:2);44 animation.setStartOffset(RexseeUtili
9、ties.getLong(style.animation_rotate_start_time,0);45 animation.setInterpolator(getInterPolator(style.animation_rotate_interpolator);46 animation.initialize(view.getWidth(),view.getHeight(),viewParent.getWidth(),viewParent.getHeight();47 catch(Exceptione)48 49 returnanimation;50 51 publicstaticAnimat
10、iongetAlphaAnimation(StyleSheetstyle,Viewview,ViewviewParent)52 Animationanimation=null;53 try54 floatfrom=Float.parseFloat(style.animation_alpha_from.replaceAll(%,)/100;55 floatto=Float.parseFloat(style.animation_alpha_to.replaceAll(%,)/100;56 animation=newAlphaAnimation(from,to);57 animation.setDu
11、ration(Integer.parseInt(style.animation_alpha_duration);58 animation.setRepeatCount(Integer.parseInt(style.animation_alpha_repeat_count);59 animation.setRepeatMode(style.animation_alpha_repeat_mode.equalsIgnoreCase(normal)?1:2);60 animation.setStartOffset(RexseeUtilities.getLong(style.animation_alph
12、a_start_time,0);61 animation.setInterpolator(getInterPolator(style.animation_alpha_interpolator);62 animation.initialize(view.getWidth(),view.getHeight(),viewParent.getWidth(),viewParent.getHeight();63 catch(Exceptione)64 65 returnanimation;66 67 publicstaticAnimationgetScaleAnimation(StyleSheetstyl
13、e,Viewview,ViewviewParent)68 Animationanimation=null;69 try70 floatscaleCenterX,scaleCenterY;71 try72 scaleCenterX=Float.parseFloat(style.animation_scale_center_x.replaceAll(%,);73 scaleCenterX=scaleCenterX/100;74 if(scaleCenterX1)scaleCenterX=1;76 catch(Exceptione)77 scaleCenterX=(float)0.5;78 79 t
14、ry80 scaleCenterY=Float.parseFloat(style.animation_scale_center_y.replaceAll(%,);81 scaleCenterY=scaleCenterY/100;82 if(scaleCenterY1)scaleCenterY=1;84 catch(Exceptione)85 scaleCenterY=(float)0.5;86 87 floatfromX=Float.parseFloat(style.animation_scale_x_from);88 floattoX=Float.parseFloat(style.anima
15、tion_scale_x_to);89 floatfromY=Float.parseFloat(style.animation_scale_y_from);90 floattoY=Float.parseFloat(style.animation_scale_y_to);91 animation=newScaleAnimation(fromX,toX,fromY,toY,Animation.RELATIVE_TO_PARENT,scaleCenterX,Animation.RELATIVE_TO_PARENT,scaleCenterY);92 animation.setDuration(Inte
16、ger.parseInt(style.animation_scale_duration);93 animation.setRepeatCount(Integer.parseInt(style.animation_scale_repeat_count);94 animation.setRepeatMode(style.animation_scale_repeat_mode.equalsIgnoreCase(normal)?1:2);95 animation.setStartOffset(RexseeUtilities.getLong(style.animation_scale_start_tim
17、e,0);96 animation.setInterpolator(getInterPolator(style.animation_scale_interpolator);97 animation.initialize(view.getWidth(),view.getHeight(),viewParent.getWidth(),viewParent.getHeight();98 catch(Exceptione)99 100 returnanimation;101 102 publicstaticAnimationgetTranslateAnimation(StyleSheetstyle,Vi
18、ewview,ViewviewParent)103 Animationanimation=null;104 try105 floatfromX=Float.parseFloat(style.animation_translate_x_from);106 floattoX=Float.parseFloat(style.animation_translate_x_to);107 floatfromY=Float.parseFloat(style.animation_translate_y_from);108 floattoY=Float.parseFloat(style.animation_tra
19、nslate_y_to);109 fromX=fromX/100;110 toX=toX/100;111 fromY=fromY/100;112 toY=toY/100;113 animation=newTranslateAnimation(Animation.RELATIVE_TO_PARENT,fromX,Animation.RELATIVE_TO_PARENT,toX,Animation.RELATIVE_TO_PARENT,fromY,Animation.RELATIVE_TO_PARENT,toY);114 animation.setDuration(Integer.parseInt
20、(style.animation_translate_duration);115 animation.setRepeatCount(Integer.parseInt(style.animation_translate_repeat_count);116 animation.setRepeatMode(style.animation_translate_repeat_mode.equalsIgnoreCase(normal)?1:2);117 animation.setStartOffset(RexseeUtilities.getLong(style.animation_translate_st
21、art_time,0);118 animation.setInterpolator(getInterPolator(style.animation_translate_interpolator);119 animation.initialize(view.getWidth(),view.getHeight(),viewParent.getWidth(),viewParent.getHeight();120 catch(Exceptione)121 122 returnanimation;123 124125 publicstaticAnimationgetRotate3dyAnimation(
22、StyleSheetstyle,Viewview,ViewviewParent)126 Animationanimation=null;127 try128 floatrotate3DCenterX,rotate3DCenterY;129 try130 rotate3DCenterX=Float.parseFloat(style.animation_rotate_3dy_center_x.replaceAll(%,);131 rotate3DCenterX=rotate3DCenterX/100;132 if(rotate3DCenterX1)rotate3DCenterX=1;134 cat
23、ch(Exceptione)135 rotate3DCenterX=(float)0.5;136 137 rotate3DCenterX=view.getWidth()*rotate3DCenterX;138 try139 rotate3DCenterY=Float.parseFloat(style.animation_rotate_3dy_center_y.replaceAll(%,);140 rotate3DCenterY=rotate3DCenterY/100;141 if(rotate3DCenterY1)rotate3DCenterY=1;143 catch(Exceptione)1
24、44 rotate3DCenterY=(float)0.5;145 146 rotate3DCenterY=view.getHeight()*rotate3DCenterY;147 floatfrom=RexseeUtilities.getFloat(style.animation_rotate_3dy_from,0f);148 floatto=RexseeUtilities.getFloat(style.animation_rotate_3dy_to,90f);149 floatrotate3DDepthZ=RexseeUtilities.getFloat(style.animation_r
25、otate_3dy_depth_z,310.0f);150 booleanreverse=(style.animation_rotate_3dy_reverse.equalsIgnoreCase(true)?true:false;151 animation=newRotate3dyAnimation(from,to,rotate3DCenterX,rotate3DCenterY,rotate3DDepthZ,reverse);152 animation.setDuration(RexseeUtilities.getInt(style.animation_rotate_3dy_duration,
26、1000);153 animation.setRepeatCount(RexseeUtilities.getInt(style.animation_rotate_3dy_repeat_count,0);154 animation.setRepeatMode(style.animation_rotate_3dy_repeat_mode.equalsIgnoreCase(normal)?1:2);155 animation.setStartOffset(RexseeUtilities.getLong(style.animation_rotate_3dy_start_time,0);156 anim
27、ation.setInterpolator(getInterPolator(style.animation_rotate_3dy_interpolator);157 animation.initialize(view.getWidth(),view.getHeight(),viewParent.getWidth(),viewParent.getHeight();158 catch(Exceptione)159 160 returnanimation;161 162163 publicstaticAnimationgetRotate3dxAnimation(StyleSheetstyle,Vie
28、wview,ViewviewParent)164 Animationanimation=null;165 try166 floatrotate3DCenterX,rotate3DCenterY;167 try168 rotate3DCenterX=Float.parseFloat(style.animation_rotate_3dx_center_x.replaceAll(%,);169 rotate3DCenterX=rotate3DCenterX/100;170 if(rotate3DCenterX1)rotate3DCenterX=1;172 catch(Exceptione)173 r
29、otate3DCenterX=(float)0.5;174 175 rotate3DCenterX=view.getWidth()*rotate3DCenterX;176 try177 rotate3DCenterY=Float.parseFloat(style.animation_rotate_3dx_center_y.replaceAll(%,);178 rotate3DCenterY=rotate3DCenterY/100;179 if(rotate3DCenterY1)rotate3DCenterY=1;181 catch(Exceptione)182 rotate3DCenterY=
30、(float)0.5;183 184 rotate3DCenterY=view.getHeight()*rotate3DCenterY;185 floatfrom=RexseeUtilities.getFloat(style.animation_rotate_3dx_from,0f);186 floatto=RexseeUtilities.getFloat(style.animation_rotate_3dx_to,90f);187 floatrotate3DDepthZ=RexseeUtilities.getFloat(style.animation_rotate_3dx_depth_z,3
31、10.0f);188 booleanreverse=(style.animation_rotate_3dx_reverse.equalsIgnoreCase(true)?true:false;189 animation=newRotate3dxAnimation(from,to,rotate3DCenterX,rotate3DCenterY,rotate3DDepthZ,reverse);190 animation.setDuration(RexseeUtilities.getInt(style.animation_rotate_3dx_duration,1000);191 animation
32、.setRepeatCount(RexseeUtilities.getInt(style.animation_rotate_3dx_repeat_count,0);192 animation.setRepeatMode(style.animation_rotate_3dx_repeat_mode.equalsIgnoreCase(normal)?1:2);193 animation.setStartOffset(RexseeUtilities.getLong(style.animation_rotate_3dx_start_time,0);194 animation.setInterpolat
33、or(getInterPolator(style.animation_rotate_3dx_interpolator);195 animation.initialize(view.getWidth(),view.getHeight(),viewParent.getWidth(),viewParent.getHeight();196 catch(Exceptione)197 198 returnanimation;199 200 publicstaticAnimationgetSkewAnimation(StyleSheetstyle,Viewview,ViewviewParent)201 An
34、imationanimation=null;202 try203 floatskewCenterX,skewCenterY;204 try205 skewCenterX=Float.parseFloat(style.animation_skew_center_x.replaceAll(%,);206 skewCenterX=skewCenterX/100;207 if(skewCenterX1)skewCenterX=1;209 catch(Exceptione)210 skewCenterX=(float)0.5;211 212 skewCenterX=view.getWidth()*ske
35、wCenterX;213 try214 skewCenterY=Float.parseFloat(style.animation_skew_center_y.replaceAll(%,);215 skewCenterY=skewCenterY/100;216 if(skewCenterY1)skewCenterY=1;218 catch(Exceptione)219 skewCenterY=(float)0.5;220 221 skewCenterY=view.getHeight()*skewCenterY;222223 floatfromX=RexseeUtilities.getFloat(
36、style.animation_skew_x_from,0f);224 floattoX=RexseeUtilities.getFloat(style.animation_skew_x_to,1f);225 floatfromY=RexseeUtilities.getFloat(style.animation_skew_y_from,0f);226 floattoY=RexseeUtilities.getFloat(style.animation_skew_y_to,1f);227228 floatskewDepthZ=RexseeUtilities.getFloat(style.animat
37、ion_skew_depth_z,310.0f);229 booleanreverse=(style.animation_skew_reverse.equalsIgnoreCase(true)?true:false;230 animation=newSkewAnimation(fromX,toX,fromY,toY,skewCenterX,skewCenterY,skewDepthZ,reverse);231 animation.setDuration(RexseeUtilities.getInt(style.animation_skew_duration,1000);232 animation.setRepeatCount(RexseeUtilities.getInt(style.animation_skew_repeat_count,0);233 animation.setRepeatMode(style.animation_skew_rep
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 智能家居系统用户安全设置手册指南
- (2026年)粉尘涉爆企业安全培训考试题及答案
- 小学师德师风考试试卷及答案
- 2026物流合作条款变更通知(4篇)
- 通知所有合作方调整供货周期函8篇
- 会计人员账务处理标准操作指南
- 重大版高中英语必修二Unit1学情验收卷(Favourite Teachers含答案)
- 2026年福建省石狮市锦峰实验学校秋季招聘编外合同教师笔试备考试题及答案解析
- 2026山东青岛胶州人才集团招聘劳务派遣制司法辅助人员13人笔试备考题库及答案解析
- 2026年甘肃省陇南徽县招聘城镇公益性岗位人员44人笔试备考题库及答案解析
- 2026年消防月专题培训(含近期火灾事故案例)
- 湖北武汉市2027届高中毕业生9月调研考试语文试卷(含解析)
- 2026秋新教材统编版九年级上册道德与法治期中素养测试卷(含答案)
- 2026年绍兴市柯桥区开发经营集团有限公司国企员工招聘9人笔试备考题库及答案详解
- 2026教科版五年级科学上册全册知识点考点
- 铝合金门窗施工方案范本
- AQT3034-2022《化工过程安全管理导则》核心要点解读
- DB 61T 5086-2023高效空调制冷机房设计标准
- 2025-2026学年四川省成都七中高一(上)期中物理试卷(含答案)
- 统招专升本英语4000词考前必背词汇表(含高频短语与记忆法)
- CRRT与体外二氧化碳清除技术联合方案
评论
0/150
提交评论