选项菜单动画

9
如何实现类似于这样的下拉动画:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="1000"
        android:fromYDelta="0"
        android:toYDelta="100%" />
</set>

如何打开“选项菜单”,可以像这个动画一样:

enter image description here

2个回答

8

只需将此行添加到您的style.xml中即可,在清单文件中定义的应用程序主要样式中添加此行。

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:popupAnimationStyle">@style/Animation</item>
</style>

<style name="Animation">
<item name="android:windowEnterAnimation">@anim/your_specific_animation</item>
<item name="android:windowExitAnimation">@anim/your_specific_animation</item>
</style>

enter image description here


对我没用。我正在尝试完全禁用动画。 - user5507535

1
在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" />

在活动中调用动画。
 Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);
    image.startAnimation(animation);//place the syntax in options menu

我创建了如下的选项菜单: "@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); return true; }" 我没有任何图片。 - Mohammad Tazehkar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接