PopupWindow animation not working

前端 未结 1 653
無奈伤痛
無奈伤痛 2021-02-02 01:27

I has a nice PopupWindow which I want to appear with an animation. I do it like this:

popup.setAnimationStyle(R.anim.appear);
popup.showAtLocation(popupMenuLayou         


        
1条回答
  •  时光说笑
    2021-02-02 02:19

    Actually, PopupWindow.setAnimationStyle expects a style with 2 entries. You'll need to have two xmls, each containing a , one for showing and the other for hiding the window. When this is done, put the following piece into values/styles.xml:

    
    

    and set your animation style to R.style.AnimationPopup. That'll do.

    I've got this information from https://github.com/lorensiuswlt/NewQuickAction3D the documentation didn't seem to mention it.

    Update:

    An update to Android SDK in 2012 have changed XML syntax. The original @android:windowEnterAnimation now became android:windowEnterAnimation. So this answer is updated accordingly.

    0 讨论(0)
提交回复
热议问题