记一次小白之路使用AndroidViewAnimations 安卓抖动动画

首先我要实现的是类似于这种动画

 

参考过得文章:https://www.jianshu.com/p/7d262563edda

我是在这篇文章的评论中看到两位大佬的对话中,看到了AndroidViewAnimations。

Github地址:https://github.com/daimajia/AndroidViewAnimations

1:添加依赖

在项目的gradle中

dependencies {
        compile 'com.android.support:support-compat:X.X.X'   
        compile 'com.daimajia.easing:library:2.0@aar'
        compile 'com.daimajia.androidanimations:library:2.3@aar'
}

这里的版本号用你

com.android.support:appcompat 使用的版本即可。

注:1.在这可能会遇到 Could not resolve com.android.support:appcompat-v7 的问题,你去settings->Build,Execution,Deployment->Gradle,取消“offline work”的勾选,让studio去下载即可。注意后期最好在改回来,这可能会导致运行项目时gradle build running 很久.

           2.有些最新android studio可能会强制使用implementation,这里你用 compile Sync Now下载完后把compile改为implementation即可。

可能有些由于网络原因的你下载会很困难,这个请自行百度即可。

 

2:使用

YoYo.with(想要使用的动画mode)
.duration(持续时间)
.repeat(持续次数)
.pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT)
.interpolate(new AccelerateDecelerateInterpolator())
.withListener(new Animator.AnimatorListener() {
    @Override
    public void onAnimationStart(Animator animation) {

    }

    @Override
    public void onAnimationEnd(Animator animation) {
    }

    @Override
    public void onAnimationCancel(Animator animation) {
        
    }

    @Override
    public void onAnimationRepeat(Animator animation) {

    }
})
.playOn(想要使用动画的按钮view);

 

注:如果想要添加动画 在中间抖动的话只设置.pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT) 是不行的,还要设置

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    if (hasFocus) {
        rope = YoYo.with(Techniques.FadeIn).duration(时间).playOn(控件);// after start,just click mTarget view, rope is not init
    }

ps:部分手机可能出现抖动后留有屏幕残留情况,可能是屏幕渲染问题 使用invalidate()可以解决

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
For making animations more real, I created another project named Android Easing Functions which is an implementations of easing functions on Android. So, we need to dependent that project. Step 1 Gradle dependencies { compile 'com.nineoldandroids:library:2.4.0' compile 'com.daimajia.easing:library:1.0.1@aar' compile 'com.daimajia.androidanimations:library:1.1.3@aar' } Maven <dependency> <groupId>com.nineoldandroids</groupId> <artifactId>library</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>com.daimajia.androidanimation</groupId> <artifactId>library</artifactId> <version>1.1.3</version> <type>apklib</type> </dependency> <dependency> <groupId>com.daimajia.easing</groupId> <artifactId>library</artifactId> <version>1.0.1</version> <type>apklib</type> </dependency> Eclipse Download the following jars, and copy them into your libs directory. NineOldAndroid-2.4.0 AndroidEasingFunctions-1.0.0 AndroidViewAnimations-1.1.3 Step 2 Just like play Yo-yo. YoYo.with(Techniques.Tada) .duration(700) .playOn(findViewById(R.id.edit_area)); Effects Attension Flash, Pulse, RubberBand, Shake, Swing, Wobble, Bounce, Tada, StandUp, Wave Special Hinge, RollIn, RollOut,Landing,TakingOff,DropOut Bounce BounceIn, BounceInDown, BounceInLeft, BounceInRight, BounceInUp Fade FadeIn, FadeInUp, FadeInDown, FadeInLeft, FadeInRight FadeOut, FadeOutDown, FadeOutLeft, FadeOutRight, FadeOutUp Flip FlipInX, FlipOutX, FlipOutY Rotate RotateIn, RotateInDownLeft, RotateInDownRight, RotateInUpLeft, RotateInUpRight RotateOut, RotateOutDownLeft, RotateOutDownRight, RotateOutUpLeft, RotateOutUpRight Slide SlideInLeft, SlideInRight, SlideInUp, SlideInDown SlideOutLeft, SlideOutRight, SlideOutUp, SlideOutDown Zoom ZoomIn, ZoomInDown, ZoomInLeft, ZoomInRight, ZoomInUp ZoomOut, ZoomOutDown, ZoomOutLeft, ZoomOutRight, ZoomOutUp Welcome contribute your amazing animation effect. :-D
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值