分享一个简单的画刷动画效果:🖌️BrushEffect

2,049 阅读1分钟

概述

前一阵子刷 即刻 的时候,在UI Movement主题下看到了这个动画效果。 当时觉得挺简单的而且效果不错,就自己试了试。 之前都是大多数时候都是用的开源库,通过这个小项目自己也完整的感受了一把开源体验🤣

这么简单的效果应该不会有人对所谓“原理”感兴趣吧🤔

感受一下

  • UI Movement上的效果

UI Movement

  • 最终效果😝

Preview

用法

  • duration:时长
  • orientation:方向
  • reverse:动画反向
  • startColor:动画开始颜色
  • endColor:动画结束颜色
  • strokeWidth:刷子宽度(1.0f为填充整个容器)
  • strokeCap:刷头性状
implementation 'com.github.tommytc:BrushEffect:1.0.0'
<com.github.tommytc.lib.brusheffect.BrushEffectLayout
        android:id="@+id/layoutTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:bel_duration="400"
        app:bel_orientation="horizontal"
        app:bel_reverse="true"
        app:bel_startColor="@color/colorAccent"
        app:bel_endColor="@color/colorAccent"
        app:bel_strokeWidth="1.0"
        app:bel_strokeCap="square">

        <Your view/>

    </com.github.tommytc.lib.brusheffect.BrushEffectLayout>
//Set interpolators
brushEffectLayout.setInInterpolator();
brushEffectLayout.setOutInterpolator();

//Set a listener
brushEffectLayout.setListener(new BrushEffectLayout.Listener() {
            public void onStart() {
            }

            public void onCover() {
            }

            public void onFinish() {
            }
        });

//Start
brushEffectLayout.brush();
//End
brushEffectLayout.hide();

Repo