我知道一个很酷的库可以在CSS,http://daneden.github.io/animate.css/中做一些很酷的对象动画。
安卓系统中也有类似的东西吗?我是说,任何一个很容易制作动画的图书馆。
谢谢
发布于 2014-03-24 15:52:36
创建动画本身是非常容易的。你不需要图书馆。有两种选择适合大多数情况,还有其他的方法来制作动画,但这些都是最重要的:
这两者在使用方式上没有太大差别,但它们可以做不同的事情。
1)查看动画:
对于视图动画,首先必须编写动画xml。在它中,你描述了动画应该是什么样子,它能持续多长时间。当然,您也可以以编程的方式创建这些动画,但是在大多数情况下用xml创建动画更好。例如,这里有两个动画xmls,一个从顶部向下滑动一个视图,另一个淡出一个视图。
滑下:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="-100%"
android:toYDelta="0%"
android:duration="1000"/>
</set>淡出:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="1"
android:toAlpha="0"
android:duration="700"/>
</set>而不是像这样加载动画:
Animation slide = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down);然后,您可以将动画应用到视图中,如下所示:
linearLayout.startAnimation(slide);您可以将这些动画组合在一个xml中,只需将多个转换/alpha/等标记放到一个集合标记中即可。您可以通过如下设置startOffset来延迟该集中一个动画的启动:
android:startOffset="500"为了完整:通过编程创建淡出动画的方式如下:
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setStartOffset(offset);
fadeOut.setDuration(duration);2)对象动画:
可以再次用代码和xml创建对象动画器,但在大多数情况下,xml更可取。这就是淡出动画与对象动画的样子:
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:propertyName="alpha"
android:valueType="floatType"
android:valueFrom="1.0"
android:valueTo="0.0"
android:duration="1000" />从一开始,对象动画师看起来可能更复杂一些,但是xml并没有太大的不同。可以说,ObjectAnimators比查看动画更可取的一点是,ObjectAnimators的功能可能要强大得多,因为它们可以对任何对象的任何属性进行动画化。例如,下面的动画会围绕它的Y轴旋转一个视图,并且没有多少人知道这样的事情是可能的:
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:propertyName="rotationY"
android:valueType="floatType"
android:valueFrom="0.0"
android:valueTo="360.0"
android:duration="5000"/>这就是如何通过编程来创建相同的动画:
ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360f);
animation.setDuration(5000);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();结果如下:

您可以从xml应用ObjectAnimator动画,如下所示:
AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.rotate_axis_y);
set.setTarget(targetView);
set.start();发布于 2017-07-27 17:58:16
链接到github。
您可以使用博迪博文解析以JSON形式导出的Adobe效果动画。
添加依赖项
compile 'com.airbnb.android:lottie:2.1.0'将JSON文件添加到资产中,并按以下方式使用
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="enter the json file name with .json extension"
app:lottie_loop="true"
app:lottie_autoPlay="true" />https://stackoverflow.com/questions/22614156
复制相似问题