且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

原产动画的android点

更新时间:2023-10-24 21:56:10

我已经做到了这一点地创建一个基于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>