how to make animation for popup window in android

后端 未结 4 1416
挽巷
挽巷 2020-12-23 19:26

I hava a popup window in my application, its appears when some button clicked I want to set fade in animation to this window, I put the xml file in \"res/anim\" folder and s

4条回答
  •  -上瘾入骨i
    2020-12-23 20:02

    I think the problem is you have provided only one set of animation style. But actually a PopupWindow requires two animations. One will be used by it when window is shown and other one to hide the window.

    This is how you should do it,

    1) Create Two Different set of animations.

    say, popup_show.xml and popup_hide.xml and add it to your anim folder which you have to create inside res folder.

    2) Now inside values folder create a xml called styles.xml and add these animations to it like this,

    
    

    3) Now set this style to your PopupWindow animation,

     popup.setAnimationStyle(R.style.Animation);
    

    Now it automatically detects window enter and exit and provides with the required animation.

提交回复
热议问题