popupwindow.setanimationstyle不工作

7cjasjjr  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(212)

按照前面关于这个问题的答案,我尝试在弹出窗口中设置动画,但没有成功:
弹出\u anim\u show.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="3000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="5"
        android:toYScale="5" />

</set>

弹出动画隐藏.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:startOffset="5000"
        android:duration="3000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0"
        android:toYScale="0" />
</set>

内部valuse\themes\xml

<style name="popup_window_animation" parent="android:Animation">
        <item name="android:windowEnterAnimation">@anim/popup_anim_show</item>
        <item name="android:windowExitAnimation">@anim/popup_anim_hide</item>
    </style>

在通过按下按钮调用的函数中

private void explain(View v) {
        LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
        View popupView = inflater.inflate(R.layout.popup_view, null);
        // create the popup window
        int width = LinearLayout.LayoutParams.WRAP_CONTENT;
        int height = LinearLayout.LayoutParams.WRAP_CONTENT;
        PopupWindow popupWindow = new PopupWindow(popupView, width, height, true);
        popupWindow.setAnimationStyle(R.style.popup_window_animation);
        popupWindow.showAtLocation(v, Gravity.TOP, 0, 300);
        popupWindow.setFocusable(true);
        popupWindow.update();
    }

弹出窗口以标准方式显示并忽略我设置的动画。。。请告诉我我做错了什么?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题