六、转场动画(Activity切换动画)
在StartActivity后即调用overridePendingTransition(int enterAnim, int exitAnim)
//in
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="500"/>
</set>
//out
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="500"/>
</set>
七、逐帧动画(Frame By Frame)
Frame by frame 指将一幅幅图片按序播放,效果像gif动画:
第一步:将用到的图片资源加到工程。
第二步:在xml里定义动画。
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/rkof" android:duration="200" />
<item android:drawable="@drawable/hkof" android:duration="200" />
<item android:drawable="@drawable/gkof" android:duration="200" />
<item android:drawable="@drawable/fkof" android:duration="200" />
<item android:drawable="@drawable/ekof" android:duration="200" />
<item android:drawable="@drawable/dkof" android:duration="200" />
<item android:drawable="@drawable/ckof" android:duration="200" />
<item android:drawable="@drawable/bkof" android:duration="200" />
<item android:drawable="@drawable/akof" android:duration="200" />
</animation-list>
<!-- android:oneshot属性为true,它将会在最后一帧停下来,如果设置
为false这个动画将循环播放 -->
第三步:定义AnimationDrawable对像
ImageView myImage = (ImageView) findViewById(R.id.rocket_image);
myImage.setBackgroundResource(R.anim.myframeanimation);
AnimationDrawable frameAnimation=(AnimationDrawable) myImage.getBackground();
第四步:播放
frameAnimation.start()
八、ApiDemo中的动画研究
1. 平滑:
Graphics/AnimateDrawables
2. 淡入淡出 :
App/Activity/Animation
3. 放大缩小 :
App/Activity/Animation && Graphics/ScaleToFit
4. 翻转 :
Views/Animation/3D Transition && Graphics/PolyToPoly
5. 透明:
App/Activity/Translucent
6. 模糊:
App/Activity/Translucent Blur
7. Overlay:
Graphics/SurfaceView OverLay
8. 反弹效果:
Views/Animation/Shake
9. 文字效果:
Views/Animation/Push && Views/Animation/Interpolators
本文介绍如何在Android应用中实现不同类型的动画效果,包括转场动画、逐帧动画等,并提供了详细的XML配置示例及代码实现方式。
&spm=1001.2101.3001.5002&articleId=82299809&d=1&t=3&u=f7ff15abd79142f1a1adee5a3b2db3ea)
1080

被折叠的 条评论
为什么被折叠?



