Android ripple animation helper, easy to create Circular Reveal. | Android水波动画帮助类,轻松实现View show/hide/startActivity()特效。(0.4.6)

Overview

CircularAnim

English | 中文

首先来看一个UI动效图。 动效来自Dribbble

效果图是是Dribbble上看到的,原作品在此。

我所实现的效果如下: Watch on YouTube

CircularAnim

Compile

最新可用版本

So,你可以如下compile该项目,也可以直接把这个类 CircularAnim 拷贝到项目里去。

add this to the the project level build.gradle file

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

add the dependency to the the app level build.gradle file

// replace {x.y.z} with the latest version.
implementation 'com.github.XunMengWinter:CircularAnim:{x.y.z}'

使用方法

为了使用起来简单,我将动画封装成CircularAnim.

现在,让按钮收缩只需一行代码,如下:

CircularAnim.hide(mChangeBtn).go();

同理,让按钮伸展开:

CircularAnim.show(mChangeBtn).go();

以View为水波触发点收缩其它View:

CircularAnim.hide(mContentLayout).triggerView(mLogoBtnIv).go();

以View为水波触发点伸展其它View:

CircularAnim.show(mContentLayout).triggerView(mLogoBtnIv).go();

水波般铺满指定颜色并启动一个Activity:

CircularAnim.fullActivity(MainActivity.this, view)
                        .colorOrImageRes(R.color.colorPrimary)
                        .go(new CircularAnim.OnAnimationEndListener() {
                            @Override
                            public void onAnimationEnd() {
                                startActivity(new Intent(MainActivity.this, EmptyActivity.class));
                            }
                        });

这里,你还可以放图片:

.colorOrImageRes(R.mipmap.img_huoer_black)

同时,你还可以设置时长、半径、转场动画、动画结束监听器等参数。

用起来非常的方便,一切逻辑性的东西都由帮助类搞定。

版本改动

  • 0.4.0 新增:triggerPoint() 方法,可指定水波扩散点,与triggerView()类似。 新增:CircularAnim.initDefaultDeployAnimators() 方法,可设置默认的动画部署器。

  • 0.3.5 新增:可以配置CircularAnim的Animator。

CircularAnim.hide(mChangeBtn2)
                          .endRadius(mProgressBar2.getHeight() / 2)
                          .deployAnimator(new CircularAnim.OnAnimatorDeployListener() {
                              @Override
                              public void deployAnimator(Animator animator) {
                                  animator.setDuration(1200L);
                                  animator.setInterpolator(new AccelerateInterpolator());
                              }
                          })
                          .go();
  • 0.3.4 新增:可在Application中初始化CircularAnim的各项默认参数:动画时长,满铺颜色。

CircularAnim.init(700, 500, R.color.colorPrimary);

源码

下面贡献源码。你可以直接新建一个CircularAnim的类,然后把下面的代码复制进去就OK了。

点此查看源码

另外,GitHub Demo 地址在此,欢迎Star,欢迎喜欢,欢迎关注,哈哈哈 ^ ^ ~

后记

需要注意的是,该帮助类适配了api 19以下的版本,因此你不需要判断版本号,但在这些低版本设备上是没有水波动画效果的,不过好的是并不会影响交互逻辑。

另外,有木有手机版或者Mac版好用的Gif转换器推荐,表示好难找。 (感谢im_brucezzAkiossDev推荐的GIF录制器:licecap,非常好用,上面的gif已经用这个录制了~)

And有没有傻瓜式发布项目到JCenter的教程推荐?看过几篇都不管用。囧 ~
 (感谢Issues区大家的推荐,我使用了YangHuitwiceYuan推荐的JitPack.io,用起来简单很多~)


iOS version is here

Comments
  • AndroidRuntime: FATAL EXCEPTION: main

    AndroidRuntime: FATAL EXCEPTION: main

    java.lang.IllegalStateException: Cannot start this animator on a detached view!
    
    at android.view.RenderNode.addAnimator(RenderNode.java:812)
    
    at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300)
    
    at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282)
    
    at android.animation.RevealAnimator.<init>(RevealAnimator.java:37)
    
    at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:55)
    
    at com.xxx.xxx.util.CircularAnimUtil$2$1.run(CircularAnimUtil.java:147)
    
    opened by nevermoresss 8
  • Cannot start this animator on a detached view!

    Cannot start this animator on a detached view!

    Hi, my code is the following:

    CircularAnim.fullActivity(MyActivity.this, view).colorOrImageRes(R.color.blue_dark).go(new CircularAnim.OnAnimationEndListener() { @Override public void onAnimationEnd() { startActivity(intent); } });

    The error is:

    Fatal Exception: java.lang.IllegalStateException: Cannot start this animator on a detached view! at android.view.RenderNode.addAnimator(RenderNode.java:817) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282) at android.animation.RevealAnimator.(RevealAnimator.java) at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:53) at top.wefor.circularanim.CircularAnim$FullActivityBuilder$1$1.run(CircularAnim.java:254) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:6102) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

    It appears on Android 5 and 6.

    Thanks.

    opened by franshua91 7
  • show之后显示不出来

    show之后显示不出来

    点击:mTvDoorTopConfirm.setEnabled(false); progressbar.setVisibility(View.VISIBLE); // 收缩按钮 CircularAnimUtil.hide(mTvDoorTopConfirm); 请求返回数据:progressbar.setVisibility(View.GONE); mTvDoorTopConfirm.setEnabled(true); // 伸展按钮 CircularAnimUtil.show(mTvDoorTopConfirm);

    代码是这样的,

    opened by nakisaren 6
  • 关于fullactivity()的时间疑问

    关于fullactivity()的时间疑问

    使用了fullactivity,然后在里面不管startanimator和returnanimator的duration设置多短,这两个动画中间似乎有一个有一个比较长的时间?就是,比如我点一个按钮触发fullactivity(实际上只是replace一个fragment), 然后会先快速出现覆盖全屏水波,然后停了大概两秒,然后水波收回,出现另外一个fragment。中间的那两秒的时间如何改?然后,是否可以设置然后水波不收回直接显示新的fragment?

    opened by yxmark 4
  • 铺满颜色启动Activity时显示延迟

    铺满颜色启动Activity时显示延迟

    您好,首先感谢提供这么好用的功能

    我感觉铺满颜色启动页面时新页面出现有点延迟。。 也就是说全屏颜色的时候会停顿一下, 有没有办法像你在文档开头放的那张UI图那样, 颜色在刚刚铺满屏幕的时候马上显示出新的页面。

    不知道这个停顿的时间是不是依赖于activity的启动时间 或者说跟设备的内存等属性也有关系 有没有可能让铺满颜色的效果像Toast那样运行在activity之上 这样在跳转页面时就可以直接启动activity 而不是等动画执行完再启动 不知道我这个想法对吗。。。

    再次感谢

    opened by qingchen1016 2
  • 你好!在Activity返回时,没有水波收缩动画

    你好!在Activity返回时,没有水波收缩动画

    @XunMengWinter 你好!在Activity返回时,没有水波收缩动画 我看到在你的demo里MainActivity启动一个EmptyActivity时有一个水波扩散动画,然后以淡入淡出的形式出现另一个EmptyActivity,然后在退出EmptyActivity的时候,会有一个水波收缩的动画,然后显示出MainActivity。我看你的代码里写的是 // 默认显示返回至当前Activity的动画. triggerView.postDelayed(new Runnable() { @Override public void run() { Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, finalRadius, 0); anim.setDuration(finalDuration); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); try { decorView.removeView(view); } catch (Exception e) { e.printStackTrace(); } } }); anim.start(); } }, 1000);

    这段代码里是紧接着在启动EmptyActivity之后的,那为什么在退出EmptyActivity之后还能看到水波收缩的动画呢?不是在启动EmptyActivity之后,MainActivity里不会执行这段代码吗?是不是因为失去焦点,然后这个triggerView的动画就不执行,然后等从EmptyActivity返回到MainActivity后得到焦点就再继续执行,所以才造成退出EmptyActivity的时候可以看到triggerView的水波收缩动画呢?

    我把EmptyActivity设置成透明的之后,再启动EmptyActivity会发现MainActivity中triggerView会在过一秒钟之后就自动执行收缩动画了。然后再按返回键就没有了之前的返回动画效果了(因为上面那段代码已经执行了)。

    opened by leguang 2
  • 几率不出现返回动画

    几率不出现返回动画

    Activity A >> ActivityB时永远会有动画, 但Activity B 执行onBackPressed()时,有一定几率不执行收回动画; onBackPressed()并没有@Override

    Activity A >> Activity B后, Activity B >> Activity C; Activity C onBackPressed()回到Activity B, 此时Activity B执行onBackPressed(),不会出现返回动画

    以上,只在Activity A中的onClick()中使用了 CircularAnimUtil.startActivity(this, f2lIntent, iv_first_layout_menu, R.color.bluegrey_900);

    opened by jesse920524 1
  • 源码中有个地方写错了吧

    源码中有个地方写错了吧

    int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2;

    这个地方应该取得view的中心坐标吧,应该是getRight - getLeft,我测试代码的时候发现水波中心确实不在正中间。

    opened by qinxiaoguang 1
Releases(0.4.6)
Owner
ice
A coder who loves art.
ice
A beautiful ripple animation for your app

Android Ripple Background A beautiful ripple animation for your app. You can easily change its color, speed of wave, one ripple or multiple ripples. S

Yao Yu 2.2k Dec 31, 2022
A library support circular imageview with rotation animation

Circular Imageview with Rotate Animation This is a fast and efficient open source custom imageview for Android that allow to easy implement disc anima

Nhien Nguyen 5 Jul 24, 2022
Android L Ripple effect wrapper for Views

Material Ripple Layout Ripple effect wrapper for Android Views Including in your project compile 'com.balysv:material-ripple:1.0.2' Check for latest v

Balys Valentukevicius 2.3k Dec 29, 2022
Implementation of Ripple effect from Material Design for Android API 9+

RippleEffect ExpandableLayout provides an easy way to create a view called header with an expandable view. Both view are external layout to allow a ma

Robin Chutaux 4.9k Dec 30, 2022
ViewAnimator view with a lollipop style reveal effect

ViewRevealAnimator Widget ViewAnimator view with a lollipop style reveal effect. Regular animation can be set (just like the default ViewAnimator) for

Alessandro Crugnola 339 Jun 3, 2022
Android Animation Easing Functions. Let's make animation more real!

Android Easing Functions This project is originally from my another project, AndroidViewAnimation, which is an animation collection, to help you make

代码家 2.5k Jan 4, 2023
DuGuang 1k Dec 14, 2022
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

LottieDialog Android Library to create Lottie animation view dialog easily with a lot of customization Why you should use Lottie Dialog You have no li

Amr Hesham 39 Oct 7, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

Android Library to create Lottie animation view dialog easily with a lot of customization

Amr Hesham 39 Oct 7, 2022
ArcAnimator helps to create arc transition animation: 2.3.+

ArcAnimator ArcAnimator helps to create arc transition animation: 14+ | ArcAnimator Demo | TransitionLoop Demo* *TransitionLoop Prototype by Min-Sang

Asyl Isakov 1.2k Dec 20, 2022
This is a simple util to create Activity transition animation

TransitionHelper This is a simple util to create Activity transition animation API compatible with Android 2.2+ 中文说明 Screenshots How to use 1.startAct

ImmortalZ 1.6k Dec 12, 2022
FPSAnimator is very easy animation library for Android TextureView and SurfaceView.

FPSAnimator A simple but powerful Tween / SpriteSheet / ParabolicMotion / animation library for Android TextureView and SurfaceView. Features The cont

Masayuki Suda 756 Dec 30, 2022
ActSwitchAnimTool make the Animation easy to implements, and it compat the version of Android 4.0 or above.

ActSwitchAnimTool As well as we know, Android 5.0 has been support more Animation(just like ViewAnimationUtils~). Maybe some developers can implements

Acropolis 573 Nov 23, 2022
Chandrasekar Kuppusamy 799 Nov 14, 2022
This library provides easy ways to add onboarding or pager screens with different animation and indicators.

WalkThroughAndroid Make amazing OnBoarding Screens easily for your app with different colorful animations, fonts, styles, and many more. Customize you

MindInventory 33 Sep 9, 2022
💳 A quick and easy flip view through which you can create views with two sides like credit cards, poker cards etc.

The article on how this library was created is now published. You can read it on this link here. →. ?? EasyFlipView Built with ❤︎ by Wajahat Karim and

Wajahat Karim 1.3k Dec 14, 2022
WindView is an Android Library to show Weather's Wind & pressure Status

WindView WindView is an Android Library to show Weather's Wind & pressure Status Screenshot Demo demo.apk Setup Step 1: Add it as a Dependency in Your

Ahmad Nemati 209 Nov 18, 2022