原产动画的android点 [英] Point of origin animation android
问题描述
我目前在做动画从材质规格设计,现在我希望实现对原产做动画的点,这是在这里显示:
I am currently doing an animation from the material spec design, now I want to enable to do a point of origin animation which is showed here:
<一个href=\"http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0B0NGgBg38lWWMXpyWDRDWDJpeDA/animation-responsiveinteraction-materialresponse-030202_PointOfOrigin_DO_001.webm\"相对=nofollow>样品动画链接
我该怎么办pre棒棒糖的动画?有没有办法在pre-棒棒糖设备做什么呢?
How can I do that animation of pre lollipop? Is there a way doing it in pre-lollipop devices?
推荐答案
我已经做到了这一点地创建一个基于XML的方法,并把它应用到您的自定义主题。
I've achieved this point of Origin creating a XML based approach and applying it to your custom Theme.
创建动画/ anim_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:fillAfter="false"
android:startOffset="200"
android:duration="200"
android:pivotX = "100%"
android:pivotY = "100%"
/>
<translate
android:fromYDelta="50%"
android:toYDelta="0"
android:startOffset="200"
android:duration="200"
/>
</set>
然后创建动画/ anim_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="0.0"
android:fillAfter="false"
android:duration="200"
android:pivotX = "100%"
android:pivotY = "100%"
/>
<translate
android:fromYDelta="0"
android:toYDelta="50%"
android:duration="200"
/>
</set>
这起源动画从弹出屏幕右下角的窗口或对话框片段。修改 pivotX
和 pivotY
来改变原点的位置
This animation origin pops a window or dialog fragment from right bottom corner of the screen. Modify pivotX
and pivotY
to change the location of the origin
定义此窗口动画在 style.xml
Define this windows animation in your style.xml
<style name="InOut.Window" parent="@android:style/Animation.Activity">
<item name="android:windowEnterAnimation">@anim/anim_in</item>
<item name="android:windowExitAnimation">@anim/anim_out</item>
</style>
最后这个动画应用到所有的窗口,你将创建自定义主题。
Lastly apply this animation to all the window for your custom Theme that you would have created.
<style ....>
...
<item name="android:windowAnimationStyle">@style/InOut.Window</item>
</style>
这篇关于原产动画的android点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!