自定义 LayoutAnimationController,一行代码为你的 ViewGroup 实例定制华丽的布局动画!

ILayoutAnimationController

项目地址:HuanHaiLiuXin/ILayoutAnimationController 

简介:自定义 LayoutAnimationController,一行代码为你的 ViewGroup 实例定制华丽的布局动画!

LayoutAnimation-布局动画-

  自定义 LayoutAnimationController,可任意定制 ViewGroup 实例内部子 View 的动画执行顺序,1 行代码就让你的 ViewGroup 拥有华丽的布局动画!
  简书:Android 开源之 ILayoutAnimationController,1 行代码让你的 ViewGroup 拥有华丽的布局动画!


截屏 GIF:

  

使用方法:

方法一:首先创建 ILayoutAnimationController 实例,然后将此实例作为参数为 ViewGroup 设置布局动画

  • 1:{@link ILayoutAnimationController#generateController(Animation, float, ILayoutAnimationController.IndexAlgorithm)}

  • 2:{@link android.view.ViewGroup#setLayoutAnimation(LayoutAnimationController)}

方法二:1 行代码直接搞定,以下两种方法任选

  • {@link ILayoutAnimationController#setLayoutAnimation(ViewGroup, int, float, ILayoutAnimationController.IndexAlgorithm)}

  • {@link ILayoutAnimationController#setLayoutAnimation(ViewGroup, Animation, float,ILayoutAnimationController.IndexAlgorithm)}

示例代码:

LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
//两行代码设置布局动画:
ILayoutAnimationController controller = ILayoutAnimationController.generateController(AnimationUtils.loadAnimation(this,R.anim.activity_open_enter),0.8f,ILayoutAnimationController.IndexAlgorithm.INDEXSIMPLEPENDULUM);
ll.setLayoutAnimation(controller);

//一行代码直接搞定:
ILayoutAnimationController.setLayoutAnimation(ll,R.anim.activity_open_enter,0.8f,ILayoutAnimationController.IndexAlgorithm.INDEXSIMPLEPENDULUM);

方法 setLayoutAnimation 中各参数介绍:
/**
 * 根据传入的动画资源 ID、单个子 View 动画延时、子 View 动画执行顺序算法枚举值 创建一个新的 CustomLayoutAnimationController 实例,
 * 将此实例作为参数为 viewGroup 设置布局动画
 * @param viewGroup
 * @param animResId
 * @param delay
 * @param indexAlgorithm
 */
public static void setLayoutAnimation(@NonNull ViewGroup viewGroup,@AnimRes int animResId, float delay,@Nullable final IndexAlgorithm indexAlgorithm){
    Animation animation = AnimationUtils.loadAnimation(viewGroup.getContext(),animResId);
    setLayoutAnimation(viewGroup,animation,delay,indexAlgorithm);
}

注意:

  • 使用 ILayoutAnimationController 获取的 ILayoutAnimationController 实例,调用 setOrder(int order)方法无效!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值