So, I have a programmatically added PopupWindow which looks like this:
dialog = new PopupWindow(context);
dialog.setContentView(ll);
dialog.showAtLocation(view, Gravity.LEFT | Gravity.TOP, -70, 0);
dialog.setWidth(w);
dialog.setHeight(h - 50);
dialog.setOutsideTouchable(true);
//The dialog.update is somewhere else, I didn't bother adding it too as it is not important for this matter (I guess)
What I want to do is to have some sort of animation effect , like it pops right from the button I press so the popup appears. (this is just an example, I just want any sort of animation).
Documentation would be ok too, as long as it is not XML based (I found those already -not really helping me).
If other details are needed ,I will comment or edit the question.
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.
android.widget.PopupWindow. This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
So, I managed to deal with this problem.
There are three simple steps to achieve the animation effect.
First: Make two XMLs that are the animation.In my case were those two following down here. 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" />
Second:
<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 comment.I will answer as fast as I can.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With