Android 翻牌动画 实现
16lz
2021-01-23
原理:由两个动画组合实现;监听第一个动画结束,开始第二个动画,具体代码如下
/** * 翻牌动画 */public void cardTurnover() { scan_barcode_iv.setImageResource(R.drawable.but_tex); if (back_scale_animation == null) { back_scale_animation = AnimationUtils.loadAnimation(getContext(), R.anim.back_scale); } back_scale_animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { scan_barcode_iv.setImageResource(R.drawable.but_icon); if (front_scale_animation == null) { front_scale_animation = AnimationUtils.loadAnimation(getContext(), R.anim.front_scale); } LinearInterpolator lir = new LinearInterpolator(); front_scale_animation.setInterpolator(lir); scan_barcode_iv.startAnimation(front_scale_animation); } @Override public void onAnimationRepeat(Animation animation) { } }); LinearInterpolator lir = new LinearInterpolator(); back_scale_animation.setInterpolator(lir); scan_barcode_iv.startAnimation(back_scale_animation);}动画一:back_scale.xml
<?xml version="1.0" encoding="utf-8"?>xmlns:android="http://schemas.android.com/apk/res/android"> android:fromXScale="1.0" android:toXScale="0.0" android:fromYScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:duration="200"/>
动画二:front_scale.xml
<?xml version="1.0" encoding="utf-8"?>xmlns:android="http://schemas.android.com/apk/res/android"> android:fromXScale="0.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:duration="200"/>
更多相关文章
- android腾讯微博吹一吹实现原理
- Android应用程序组件Content Provider在应用程序之间共享数据的
- Android弹性动画三种实现方式
- Android View 的工作原理浅析
- android中四个典型动画设置
- Android应用程序组件Content Provider在应用程序之间共享数据的
- Android Debug Bridge 技术实现原理
- Android Property Animation属性动画初识:透明渐变(1)
- android移动补间动画