集册 Android&Java 技术笔记 安卓系统动效专题

安卓系统动效专题

欢马劈雪     最近更新时间:2020-08-04 05:37:59

113

demo

  • animate
  • plaid
  • android-topeka

系统API

入门博客系列

Backport lib

自定义Activity的过场动效

Fragment过场动效

mFragmentManager.beginTransaction()
                .setCustomAnimations(R.anim.slide_down, R.anim.slide_up, R.anim.slide_down, R.anim.slide_up)
                .add(android.R.id.content, new SelfHomeFragment(), SelfHomeFragment.class.getName())
                .commit();

setCustomAnimations调用的顺序一定要是第一个,否则会不起效。
使用add、remove,则会有两层Fragment同时显示的效果。

Fragment share animation

Transition Animations

  • property animator
    • View.animate()方法返回一个ViewPropertyAnimator,它包含对View各种属性的动画改变API。
    • 通过动画API改变view的属性(位置),动画结束后,View会停留在结束时的状态(位置、大小等);
    • ObjectAnimatorObjectAnimator.ofFloat(Object target, String propertyName, float... values),该方法将通过反射对View进行动画展示。
  • 基于Scene的动效:系统自动检测两个Scene之间的区别,然后用动效进行过渡;
    • Scene可以用代码创建,也可以由xml定义;
    • ChanngeBoundsFadeAutoTransition,...,TransitionSetAutoTransition.setOrdering()TransitionSet.setOrdering()
    • 变化的View要有公共的父Layout;
    • 无公共父Layout:setReparent(),但是效果并不是十分完美;
  • Material design的动画效果
    • RippleDrawable, backport to API 14
    • CircularReveal, backport to API 9
    • AnimatedVectorDrawable, backport to API 14
    • SharedElementEnterTransition, backport to API 14
    • AnimatedStateListDrawable