2

How to set an translate animation to a PopupWindow while it's location changed. I have search many articles but almost is about the show animation and dismiss animation.I used PopupWindow.update() but it just work without animation.How can i do that?here is my code:

if (mPopupWindow.isShowing()) {
        mPopupWindow.update(x, y, -1, -1, true);
    } else {
        mPopupWindow.showAtLocation(parent, Gravity.NO_GRAVITY, x, y);
    }
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
chenj
  • 21
  • 3

1 Answers1

-1
<style name="AnimationPopup">
    <item name="android:windowEnterAnimation">@anim/popup_show</item>
    <item name="android:windowExitAnimation">@anim/popup_hide</item>

</style>

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

<translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromYDelta="0"
 android:toYDelta="100%"
 android:duration="1000"
/>
  • @user8356857: This answer is not related, This is how PopupWindow animates when enter and exits. But the question is more related to the updating its position from one screen location to another. so keep in mind when update method is called, none of them (Enter and Exit animation) would trigger. Enter animation would only trigger for the first time when PopupWindow shows and Exit animation would only trigger for the last time when a user dismisses the PopupWindow. – Shoaib Mushtaq Sep 25 '20 at 09:49