introduction

official site:http://facebook.github.io/rebound
github : https://github.com/facebook/rebound
Rebound是facebook推出的一个弹性动画库,可以让动画看起来真实自然,像真实世界的物理运动,带有力的效果,使用的参数则是facebook的origami中使用的。
官网上有一个简单的JS版本来做demo,如果说到evernote、LinkedIn、flow等应用也在使用这个动画库,是不是会显得更厉害些呢。

具体效果,可以看看QQ空间 Android独立版客户端中,抽屉打开的icon效果,以及底部加号点开后的icon效果,是我当年在的时候做的。

usage

1
2
3
4
5
6
7
8
9
10
Spring spring = mSpringSystem
.createSpring()
.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(86, 7))
.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
float value = (float) spring.getCurrentValue();
ViewHelper.setTranslationX(view, value);
}
});

上面的短短代码就可以给一个view加上自然的从左向右进入回弹效果。

类似地

1
2
3
4
5
6
7
8
9
10
11
12
Spring spring = mSpringSystem
.createSpring()
.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(86, 7))
.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
float value = (float) spring.getCurrentValue();
float scale = 1f - value;
ViewHelper.setScaleX(mItemIconViewList.get(index), scale);
ViewHelper.setScaleY(mItemIconViewList.get(index), scale);
}
});

就可以给view加上一个从小变大然后略有回弹的效果。

如果想要做很多view的连锁动画怎么办?Rebound也提供了SpringChain这个接口。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
for (int i = 0; i < viewCount; i++) {
final View view = new View(context);
view.setLayoutParams(
new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
1f));
mSpringChain.addSpring(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
float value = (float) spring.getCurrentValue();
view.setTranslationX(value);
}
});
int color = (Integer) evaluator.evaluate((float) i / (float) viewCount, startColor, endColor);
view.setBackgroundColor(color);
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return handleRowTouch(v, event);
}
});
mViews.add(view);
rootView.addView(view);
} getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
List<Spring> springs = mSpringChain.getAllSprings();
for (int i = 0; i < springs.size(); i++) {
springs.get(i).setCurrentValue(-mViews.get(i).getWidth());
}
postDelayed(new Runnable() {
@Override
public void run() {
mSpringChain
.setControlSpringIndex(0)
.getControlSpring()
.setEndValue(0);
}
}, 500);
}
});

就做出了一个view和view的牵引位移动画效果。

让动画不再僵硬:Facebook Rebound Android动画库介绍的更多相关文章

  1. Facebook Rebound 弹性动画库 源码分析

    Rebound源码分析 让动画不再僵硬:Facebook Rebound Android动画库介绍一文中介绍了rebound这个库. 对于想体验一下rebound的效果,又懒得clone和编译代码的, ...

  2. rebound是facebook的开源动画库

    网址:http://www.jcodecraeer.com/a/opensource/2015/0121/2338.html 介绍: rebound是facebook的开源动画库.可以认为这个动画库是 ...

  3. 一个使用openGL渲染的炫丽Android动画库二(碎片化曲面动画)

    续一个使用openGL渲染的炫丽Android动画库 MagicSurfaceView v1.1.0发布, 新增碎片化曲面动画 地址:https://github.com/gplibs/android ...

  4. Animate.css_css3动画库介绍

    插件描述:Animate.css内置了很多典型的css3动画,兼容性好使用方便. Animate.css是一个有趣的,跨浏览器的css3动画库.很值得我们在项目中引用. 用法 1.首先引入animat ...

  5. 一个使用openGL渲染的炫丽Android动画库

    android-magic-surface-view 这是一个 android 动画特效库, 可以实现各种炫酷动画. github地址: https://github.com/gplibs/andro ...

  6. Facebook的Pop动画库相关资料

    https://github.com/facebook/pop http://www.cocoachina.com/industry/20140507/8339.html http://www.ui. ...

  7. 【轮子】发现一个效果丰富酷炫的Android动画库

    没有什么比发现一个好轮子更让人开心的了. 这个库分分钟提高交互体验 :AndroidViewAnimations 一张图说明一切 配置和使用也相当简单 GitHub地址

  8. Android的Activity切换动画特效库SwitchLayout,视图切换动画库,媲美IOS

    由于看了IOS上面很多开发者开发的APP的视图界面切换动画体验非常好,这些都是IOS自带的,但是Android的Activity等视图切换动画并没有提供原生的,所以特此写了一个可以媲美IOS视图切换动 ...

  9. Facebook开源动画库 POP-POPBasicAnimation运用

    动画在APP开发过程中还是经常出现,将花几天的时间对Facebook开源动画库 POP进行简单的学习:本文主要针对的是POPBasicAnimation运用:实例源代码已经上传至gitHub,地址:h ...

随机推荐

  1. Apache Rewrite url重定向功能的简单配置

    http://www.jb51.net/article/24435.htm 1.Apache Rewrite的主要功能 就是实现URL的跳转和隐藏真实地址,基于Perl语言的正则表达式规范.平时帮助我 ...

  2. Android Metro风格的Launcher开发系列第二篇

    前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客http://www.cnblogs.com/2010wuhao/p ...

  3. oracle里面的时间转字符串to_char(),字符串转时间to_date(),以及substr和instr的使用。

    工作中编写过的一条语句 select * from Bt_Holiday where to_char(Setting_DATE,'YYYY')=Substr('2015-03-00',1,4) AND ...

  4. serialize

    Jquery的serialize()方法用于将表单元素转换为查询字符串格式, Submit按钮及File选择元素是不能序列化的. $('input:button').click(function() ...

  5. mysql innodb 数据打捞(一)innodb 页面结构特征

    如果文件系统损坏或意外删除了数据库文件,只要磁盘空间没有被覆盖,其实数据都还在磁盘的扇区中,还是可以恢复出来的,有些通用的文件恢复工具好象也可以恢复文件 ,但这里要研究的是在通用文件 恢复工具失效的时 ...

  6. 05_例子讲解:rlCollisionDemo.exe

    碰撞检测的例子: "E:\Program Files (x86)\rl-0.6.2\bin\rlCollisionDemo.exe" "E:\Program Files ...

  7. [Guava官方文档翻译] 6. 用Guava辅助Throwable异常处理 (Throwables Explained)

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3537508.html ,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体 ...

  8. hdu 4300 Clairewd’s message KMP应用

    Clairewd’s message 题意:先一个转换表S,表示第i个拉丁字母转换为s[i],即a -> s[1];(a为明文,s[i]为密文).之后给你一串长度为n<= 100000的前 ...

  9. linux管道的容量和内部组织方式

    1.管道容量  count=65536,即64KB #include<stdio.h> #include<sys/types.h> #include<unistd.h&g ...

  10. jdbc 连接Oracle informix Mysql

    package com.basicSql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Res ...