diff --git a/README.md b/README.md index fb1bf5561bc624300cc04a74d147b5f5b3b75fa2..b98703cefd3d2706c7f93a9dd5175efba80b24b2 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ dependencies { 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 ## 使用说明 -使用该库非常简单, +1、简单使用 ``` 监听TouchEvent事件 @@ -49,6 +49,63 @@ AdditiveAnimatorColor.componentColor(mComponent, starColor, endColor, mAnimation 详情请参考demo +``` +2、支持动态设置动画时间及路径绘制 +``` +AdditiveAnimator.animate(mComponent).setDuration(3200).setTimeCurveType(Animator.CurveType.LINEAR) + .xyRotationAlongPath(path2) + .setRepeatCount(AnimatorValue.INFINITE) + .start(); +``` +3、支持动画延时时间,多视图相同属性动画 +``` +// 为多个视图设置相同属性的动画,而无需循环。 +new AdditiveAnimator().target(myView1, myView2).alpha(0).start(); + +// 为每一个视图动画开启设置延时 +new AdditiveAnimator().targets(Arrays.asList(myView1, myView2), 50L).alpha(0).start(); +``` +4、控制显隐 +``` +// 直接控制显隐 +AdditiveAnimator.animate(view) + .fadeVisibility(View.GONE) // fades out the view, then sets visibility to GONE + .start(); + +// 通过淡入淡出效果实现简单的动画效果 +AdditiveAnimator.animate(view) + // the first param decides whether the view should be GONE or INVISIBLE, + // the second one decides how much to move the view as it fades out + .visibility(ViewVisibilityAnimation.fadeOutAndTranslateX(true, 100f)) // only move x + .visibility(ViewVisibilityAnimation.fadeOutAndTranslateY(true, 100f)) // only move y + .visibility(ViewVisibilityAnimation.fadeOutAndTranslate(true, 100f, 100f)) // move x and y + .start(); +``` +5、通过then连接块切换视图状态 +``` +new AdditiveAnimator() + .targets(normalViews) + .scale(1f) // normal + .then() + .target(highlightedView) + .scale(1.2f) // highlighted + .start(); + +new AdditiveAnimator() + .targets(normalViews) + .state(MyViewState.NORMAL) + .then() + .target(highlightedView) + .state(MyViewState.HIGHLIGHTED) + .start(); +``` +6、自定义动画属性 +``` +new AdditiveRectAnimator().setDuration(1500).setRepeatCount(AnimatorValue.INFINITE) + .targets(mRects, delayBetweenAnimations) + .size(DpConverter.dip2px(mContext, 70)) + .cornerRadius(DpConverter.dip2px(mContext, 60)) + .start(); ``` ## 测试信息 CodeCheck代码测试无异常 diff --git a/build.gradle b/build.gradle index 59514a51b31c0bda8ab56b2a2c7f2c3dcceadeb8..0eccf893141f800925a463262d28bc4bbe85a30c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ - apply plugin: 'com.huawei.ohos.app' @@ -8,7 +7,7 @@ ohos { compatibleSdkVersion 5 } } - + buildscript { repositories { maven { @@ -17,11 +16,11 @@ buildscript { maven { url 'https://developer.huawei.com/repo/' } - jcenter() + jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' + classpath 'com.huawei.ohos:hap:2.4.5.5' + classpath 'com.huawei.ohos:decctest:1.2.5.1' } } @@ -33,6 +32,6 @@ allprojects { maven { url 'https://developer.huawei.com/repo/' } - jcenter() + jcenter() } }