选项菜单动画
Option Menu Animation
我怎样才能制作这样的向下滑动动画:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="100%" />
</set>
打开“选项菜单”。喜欢这个动画:
在 anim 文件夹中创建一个 xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0" />
在activity调用动画
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
image.startAnimation(animation);//place the syntax in options menu
只需将此行添加到您的 style.xml
请将此添加到您在清单
中定义的应用程序主样式
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:popupAnimationStyle">@style/Animation</item>
</style>
style.xml :
<style name="Animation">
<item name="android:windowEnterAnimation">@anim/your_specific_animation</item>
<item name="android:windowExitAnimation">@anim/your_specific_animation</item>
</style>
我怎样才能制作这样的向下滑动动画:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="100%" />
</set>
打开“选项菜单”。喜欢这个动画:
在 anim 文件夹中创建一个 xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0" />
在activity调用动画
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
image.startAnimation(animation);//place the syntax in options menu
只需将此行添加到您的 style.xml 请将此添加到您在清单
中定义的应用程序主样式<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:popupAnimationStyle">@style/Animation</item>
</style>
style.xml :
<style name="Animation">
<item name="android:windowEnterAnimation">@anim/your_specific_animation</item>
<item name="android:windowExitAnimation">@anim/your_specific_animation</item>
</style>