ZetaPR
ZetaPR

Reputation: 1003

Popup Window Animation not working

I'm trying to animate a Popup Window when is shown from the bottom of the view with a push_up in animation an when is close with a push_up out animation. But is not working, the popup shows normally with deafult animation (very fast). Here is my code:

push_up_in.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="1000"
        android:fromYDelta="100%p"
        android:toYDelta="0" />

    <alpha
        android:duration="1000"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
</set>

push_up_out.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="1000"
        android:fromYDelta="0"
        android:toYDelta="-100%p" />

    <alpha
        android:duration="1000"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />
</set>

styles.xml

<style name="popup_anim">
    <item name="android:windowEnterAnimation">@anim/push_up_in</item>
    <item name="android:windowExitAnimation">@anim/push_up_out</item>
</style>

and where the Popup Window is shown in code:

final PopupWindow pw = new PopupWindow(popview, 100, 100, true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.setOutsideTouchable(true);
pw.setAnimationStyle(R.style.popup_anim);
pw.showAtLocation(this.findViewById(R.id.map_layout),
                    Gravity.BOTTOM, 0, 0);
View map = (View) findViewById(R.id.map);
int mapwidth = map.getWidth();
int mapheight = map.getHeight();
int popuph = (int) (mapheight * 0.3);
pw.update(mapwidth, popuph);

Any thoughts?

Upvotes: 3

Views: 1108

Answers (1)

Max Izrin
Max Izrin

Reputation: 955

I don't see where you set the content view, there may be nothing to show. And if that's not it, try passing null to the background drawable, and setting a background to the layout within, that solved some problems with the color displaying wrong on my project.

Upvotes: 1

Related Questions