animition动画的加入

很多时候我们把PopupWindow用作自定义的菜单,需要一个从底部向上弹出的效果,这就需要为PopupWindow添加动画。

在工程res下新建anim文件夹,在anim文件夹先新建两个xml文件

menu_bottombar_in.xml

复制代码
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="250"
        android:fromYDelta="100.0%"
        android:toYDelta="0.0" />

</set>
复制代码

menu_bottombar_out.xml

复制代码
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="250"
        android:fromYDelta="0.0"
        android:toYDelta="100%" />

</set>
复制代码

在res/value/styles.xml添加一个sytle

    <style name="anim_menu_bottombar">
        <item name="android:windowEnterAnimation">@anim/menu_bottombar_in</item>
        <item name="android:windowExitAnimation">@anim/menu_bottombar_out</item>
    </style>
原文地址:https://www.cnblogs.com/imqsl/p/6633153.html