【开源】rebound
rebound
- https://github.com/facebook/rebound
介绍:
rebound是facebook的开源动画库。可以认为这个动画库是独立于android Framework之外的一种动画实现。运行效果:
![]()
使用说明:
1.首先添加Rebound库依赖
Rebound提供了三种方式引入,当然在Android Studio下还是推荐使用Gradle方式。
-
添加Gradle依赖(推荐)
|
1
2
3
|
dependencies {compile 'com.facebook.rebound:rebound:0.3.6'} |
-
下载Rebound Jar文件,导入工程
-
添加Maven依赖
|
1
2
3
4
5
|
<dependency> <groupId>com.facebook.rebound</groupId> <artifactId>rebound</artifactId> <version>0.3.6</version></dependency> |
2.首先创建一个SpringSystem对象
|
1
|
SpringSystem mSpringSystem = SpringSystem.create(); |
3.添加一个“弹簧”到系统
|
1
|
Spring mSpring = mSpringSystem.createSpring(); |
4.添加监听器
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
mSpring.addListener(this);//实现SpringListener接口,需要实现下面方法@Override public void onSpringUpdate(Spring spring) {}@Override public void onSpringAtRest(Spring spring) {}@Override public void onSpringActivate(Spring spring) {}@Override public void onSpringEndStateChange(Spring spring) {} |
5.设置动画结束值
|
1
|
mSpring.setEndValue(1f); |
6.在弹簧更新数据是对图片进行对应伸缩
|
1
2
3
4
5
6
|
public void onSpringUpdate(Spring spring) { float value = (float) spring.getCurrentValue(); float scale = 1f - (value * 0.5f); mImageToAnimate.setScaleX(scale); mImageToAnimate.setScaleY(scale);} |
通过上面几个步骤可以很方便的实现弹簧阻尼效果的图片伸缩。
参考 :http://qichaochen.github.io/2014/11/21/107-Facebook-Rebound-Demo/
posted on 2015-04-13 09:21 wasdchenhao 阅读(214) 评论(0) 收藏 举报

浙公网安备 33010602011771号