1. 组件动画

设置ViewGrouplayoutAnimation属性,指定组件动画配置。

android:layoutAnimation="@anim/anim_layout_animation"

配置属性

  • delay,动画播放延迟时间
  • animationOrder,子控件播放动画顺序。animationOrder的值为normalreverserandom
  • animation,指定补间动画

组件动画anim_layout_animation.xml文件

补间动画anim_in_from_right.xml文件

效果如下

2. 代码实现

LayoutAnimationController可以实现组件动画。

Animation animation = AnimationUtils.loadAnimation(this, R.anim.anim_in_from_right);LayoutAnimationController controller = new LayoutAnimationController(animation);controller.setDelay(0.1f);controller.setOrder(LayoutAnimationController.ORDER_NORMAL);ViewGroup container = findViewById(R.id.container);container.setLayoutAnimation(controller);container.startLayoutAnimation();

3. 指定播放顺序

自定义LayoutAnimationController,并覆盖getTransformedIndex(AnimationParameters)方法,同时指定自定义顺序setOrder(-1)

private static class CustomLayoutAnimationController extends LayoutAnimationController {    CustomLayoutAnimationController(Animation animation) {        super(animation);    }    @Override    protected int getTransformedIndex(AnimationParameters params) {        if (getOrder() < 0) {            int index = params.index;            int count = (params.count + 1) / 2;            if (index < count) {                return count - 1 - params.index;            } else {                return params.index - count;            }        } else {            return super.getTransformedIndex(params);        }    }}

效果如下

相关文章
Animation动画
帧动画
属性动画
组件动画
Transition动画

更多相关文章

  1. Android(安卓)动画框架
  2. android发展计划,技术栈
  3. Android(安卓)buttom textview 颜色平滑过渡的动画效果
  4. Spring for android实现客户端与服务器的通信
  5. Android(安卓)- ToDoList 详解
  6. Android布局动画之animateLayoutChanges与LayoutTransition
  7. Android(安卓)属性动画 源码解析 深入了解其内部实现
  8. Android用户界面UI组件--AdapterView及其子类(三) ExpandableLis
  9. Android(安卓)Animation 动画效果介绍

随机推荐

  1. 装Android(安卓)Studio时新项目gradle报
  2. Android文档学习03_Intent
  3. Android小项目之八 界面细节
  4. Android(安卓)h264 硬编码 软编码
  5. Android初始化的时候获取加载的布局的宽
  6. android 事件处理机制之requestDisallowI
  7. 疯狂Android第一章:Android环境配置以及
  8. Android(安卓)TextView的drawLeft、drawR
  9. Android如何打开/关闭系统解锁服务?—典型
  10. Android(安卓)quikboot