android 飘雪动画,ViewAnimator: A fluent Android animation library。安卓动画库,加入了一些不错的动画,如:wave、fall、shake、fla...

ViewAnimator

API-9%2B-green.svg

Android%20Arsenal-ViewAnimator-brightgreen.svg?style=flat

A fluent Android animation library !

a87e442c578b533b3a28753b0fb3486a.png

#Usage

Animate multiple view from one method

ViewAnimator

.animate(image)

.translationY(-1000, 0)

.alpha(0,1)

.andAnimate(text)

.dp().translationX(-20, 0)

.interpolator(new DecelerateInterpolator())

.duration(2000)

.thenAnimate(image)

.scale(1f,0.5f,1f)

.interpolator(new AccelerateInterpolator())

.duration(1000)

.start();

59bb73c95856f4eb2a657469e4364b5e.gif

Without ViewAnimator

AnimatorSet animatorSet = new AnimatorSet();

animatorSet.playTogether(

ObjectAnimator.ofFloat(image,"translationY",-1000,0),

ObjectAnimator.ofFloat(image,"alpha",0,1),

ObjectAnimator.ofFloat(text,"translationX",-200,0)

);

animatorSet.setInterpolator(new DescelerateInterpolator());

animatorSet.setDuration(2000);

animatorSet.addListener(new AnimatorListenerAdapter(){

@Override public void onAnimationEnd(Animator animation) {

AnimatorSet animatorSet2 = new AnimatorSet();

animatorSet2.playTogether(

ObjectAnimator.ofFloat(image,"scaleX",1f,0.5f,1f),

ObjectAnimator.ofFloat(image,"scaleY",1f,0.5f,1f)

);

animatorSet2.setInterpolator(new AccelerateInterpolator());

animatorSet2.setDuration(1000);

animatorSet2.start();

}

});

animatorSet.start();

#More

b523fb9bdff9b2423483e880601e1478.gif

Add same animation on multiples view

ViewAnimator

.animate(image,text)

.scale(0,1)

.start();

Add listeners

ViewAnimator

.animate(image)

.scale(0,1)

.onStart(() -> {})

.onStop(() -> {})

.start();

Use DP values

ViewAnimator

.animate(image)

.dp().translationY(-200, 0)

.start();

Animate Height / Width

ViewAnimator

.animate(view)

.waitForHeight() //wait until a ViewTreeObserver notification

.dp().width(100,200)

.dp().height(50,100)

.start();

Color animations

ViewAnimator

.animate(view)

.textColor(Color.BLACK,Color.GREEN)

.backgroundColor(Color.WHITE,Color.BLACK)

.start();

Rotation animations

ViewAnimator

.animate(view)

.rotation(360)

.start();

Custom animations

ViewAnimator

.animate(text)

.custom(new AnimationListener.Update() {

@Override public void update(TextView view, float value) {

view.setText(String.format("%.02f",value));

}

}, 0, 1)

.start();

.shake();

.bounce().interpolator(new BounceInterpolator());

.bounceIn();

.bounceOut();

.flash();

.flipHorizontal();

.flipVertical();

.wave();

.tada();

.rubber();

.pulse();

.standUp();

.swing();

.wobble();

.zoomIn();

.zoomOut();

.rollIn();

.rollOut();

.fadeIn();

.fadeOut();

.fall();

.newsPaper();

.slit();

.slideLeftIn();

.slideRightIn();

.slideTopIn();

.slideBottomIn();

.path(...);

.svgPath(...);

final int[] START_POINT = new int[]{ 300, 270 };

final int[] BOTTOM_POINT = new int[]{ 300, 400 };

final int[] LEFT_CONTROL_POINT = new int[]{ 450, 200 };

final int[] RIGHT_CONTROL_POINT = new int[]{ 150, 200 };

Path path = new Path();

path.moveTo(START_POINT[0], START_POINT[1]);

path.quadTo(RIGHT_CONTROL_POINT[0], RIGHT_CONTROL_POINT[1], BOTTOM_POINT[0], BOTTOM_POINT[1]);

path.quadTo(LEFT_CONTROL_POINT[0], LEFT_CONTROL_POINT[1], START_POINT[0], START_POINT[1]);

path.close();

ViewAnimator.animate(view).path(path).repeatCount(ViewAnimator.INFINITE).start();

d="M 42.266949,70.444915 C 87.351695,30.995763 104.25847,28.177966 104.25847,28.177966 l 87.3517,36.631356 8.45339,14.088983 L 166.25,104.25847 50.720339,140.88983 c 0,0 -45.0847458,180.33898 -39.449153,194.42797 5.635594,14.08898 67.627119,183.15678 67.627119,183.15678 l 16.90678,81.7161 c 0,0 98.622885,19.72457 115.529665,22.54237 16.90678,2.8178 70.44491,-22.54237 78.8983,-33.81356 8.45339,-11.27118 76.08051,-107.07627 33.81356,-126.80085 -42.26695,-19.72457 -132.43644,-56.35593 -132.43644,-56.35593 0,0 -33.81356,-73.26271 -19.72458,-73.26271 14.08899,0 132.43644,73.26271 138.07204,33.81356 5.63559,-39.44915 19.72457,-169.0678 19.72457,-169.0678 0,0 28.17797,-25.36017 -28.17796,-19.72457 -56.35593,5.63559 -95.80509,11.27118 -95.80509,11.27118 l 42.26695,-87.35169 8.45339,-28.177968";

/>

final String SVG_PATH = "M 42.266949,70.444915 C 87.351695,30.995763 104.25847,28.177966 104.25847,28.177966 l 87.3517,36.631356 8.45339,14.088983 L 166.25,104.25847 50.720339,140.88983 c 0,0 -45.0847458,180.33898 -39.449153,194.42797 5.635594,14.08898 67.627119,183.15678 67.627119,183.15678 l 16.90678,81.7161 c 0,0 98.622885,19.72457 115.529665,22.54237 16.90678,2.8178 70.44491,-22.54237 78.8983,-33.81356 8.45339,-11.27118 76.08051,-107.07627 33.81356,-126.80085 -42.26695,-19.72457 -132.43644,-56.35593 -132.43644,-56.35593 0,0 -33.81356,-73.26271 -19.72458,-73.26271 14.08899,0 132.43644,73.26271 138.07204,33.81356 5.63559,-39.44915 19.72457,-169.0678 19.72457,-169.0678 0,0 28.17797,-25.36017 -28.17796,-19.72457 -56.35593,5.63559 -95.80509,11.27118 -95.80509,11.27118 l 42.26695,-87.35169 8.45339,-28.177968";

ViewAnimator

.animate(view)

.svgPath(SVG_PATH)

.repeatMode(ViewAnimator.REVERSE)

.repeatCount(2)

.start();

#Download

Add into your build.gradle

download.svg

compile 'com.github.florent37:viewanimator:1.0.2@aar'

compile 'com.nineoldandroids:library:2.4.0'

#Community

Looking for contributors, feel free to fork !

#Credits

Author: Florent Champigny

Contributor: 李玉江(liyujiang)

bf8fac1dfe4cb32fdeb9fb73d16fdd75.png

71253098ae5cf820d6221eb0f4465800.png

fefe6af45913ca6b4ca765903c98bafe.png

#License

Copyright 2015 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值