So, I managed to deal with this problem.
There are three easy steps to achieve an animation effect.
First: Make two XML files that are animations. In my case, these were the next two. animation_on.xml
<scale xmlns:android="http://schemas.android.com/apk/res/android" android:toXScale="1.0" android:fromXScale="0.0" android:toYScale="1.0" android:fromYScale="0.0" android:pivotX="0%" android:pivotY="50%" android:startOffset="100" android:duration="300" />
animation_off.xml
<scale xmlns:android="http://schemas.android.com/apk/res/android" android:toXScale="0.0" android:fromXScale="1.0" android:toYScale="0.0" android:fromYScale="1.0" android:pivotX="0%" android:pivotY="50%" android:startOffset="100" android:duration="300" />
Secondly:
<style name="animationName" parent="android:Animation"> <item name="android:windowEnterAnimation">@anim/animation_on</item> <item name="android:windowExitAnimation">@anim/animation_off</item> </style>
Third:
dialog = new PopupWindow(context); // ....other code, whatever you want to do with your popupWindow (named dialog in our case here) dialog.setAnimationStyle(R.style.animationName);
If anyone needs help with this, leave a comment. I will answer as soon as I can.
Vlad
source share