Animation in `Popup`
<p>I am working on the <code>PopupWindow</code> animation. But the Animation code is not working.</p>

<p>Here is my code.</p>

<p>This is <code>FragmentActivity.java</code></p>

<pre><code>public class AbstractActivity extends FragmentActivity {

private Point p;

PopupWindow popup;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
}

public void onPopupLeft(View v) {

    // Open popup window
    if (p != null)
        showPopupLeft(AbstractActivity.this, p);

}

public void onPopupRight(View v) {
    showPopupRight(AbstractActivity.this, p);
}

// Get the x and y position after the button is draw on screen
// (It's important to note that we can't get the position in the onCreate(),
// because at that stage most probably the view isn't drawn yet, so it will
// return (0, 0))
@Override
public void onWindowFocusChanged(boolean hasFocus) {

    int[] location = new int[2];
    ImageButton imglogo = (ImageButton) findViewById(R.id.logo);

    // Get the x, y location and store it in the location[] array
    // location[0] = x, location[1] = y.
    imglogo.getLocationOnScreen(location);

    // Initialize the Point with x, and y positions
    p = new Point();
    p.x = location[0];
    p.y = location[1];
}

// The method that displays the popup.
private void showPopupLeft(Activity context, Point p) {

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    int width = metrics.widthPixels;
    int height = metrics.heightPixels;

    Log.i("Windows Width", width + "");
    Log.i("Windows Hight", height + "");

    int popupWidth = (70 * width) / 100;
    int popupHeight = (70 * height) / 100;

    int y = (height * 14) / 100;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) context
            .findViewById(R.id.popup);

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.popup_layout_left, viewGroup,
            true);

    // Creating the PopupWindow
    popup = new PopupWindow(layout, popupWidth, popupHeight, true);

    popup.setBackgroundDrawable(new BitmapDrawable());

    popup.setAnimationStyle(R.style.PopupAnimation);

    popup.setOutsideTouchable(true);

    popup.setTouchInterceptor(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                popup.dismiss();
                return true;
            }
            return false;
        }
    });
    popup.showAtLocation(layout, Gravity.TOP | Gravity.LEFT, 10, y);

}
}
</code></pre>

<p>And Here is my animation <code>XML's</code> is in anim/grow_from_topleft_to_bottomright.xml and anim/shrink_from_bottomright_to_topleft.xml</p>

<p>1.grow_from_topleft_to_bottomright.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;set xmlns:android="http://schemas.android.com/apk/res/android" &gt;

&lt;scale
    android:duration="@android:integer/config_shortAnimTime"
    android:fromXScale="0.3"
    android:fromYScale="0.3"
    android:pivotX="0%"
    android:pivotY="0%"
    android:toXScale="1.0"
    android:toYScale="1.0" /&gt;

&lt;alpha
    android:duration="@android:integer/config_shortAnimTime"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toAlpha="1.0" /&gt;

&lt;/set&gt;
</code></pre>

<p>2.shrink_from_bottomright_to_topleft.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;set xmlns:android="http://schemas.android.com/apk/res/android" &gt;

&lt;scale
    android:duration="@android:integer/config_shortAnimTime"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="0%"
    android:pivotY="0%"
    android:toXScale="0.3"
    android:toYScale="0.3" /&gt;

&lt;alpha
    android:duration="@android:integer/config_shortAnimTime"
    android:fromAlpha="1.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toAlpha="0.0" /&gt;

&lt;/set&gt;
</code></pre>

<p>And in style.xml</p>

<pre><code>&lt;style name="PopupAnimation" mce_bogus="1" parent="android:Animation"&gt;
    &lt;item name="android:windowEnterAnimation"&gt;@anim/grow_from_topleft_to_bottomright&lt;/item&gt;
    &lt;item name="android:windowExitAnimation"&gt;@anim/shrink_from_bottomright_to_topleft&lt;/item&gt;
&lt;/style&gt;
</code></pre>
