我知道存在一個類似於這個問題的主題,但我無法確定如何使用我的代碼工作。我有一個popupwindow,(我甚至不知道這是否是最好的方式來做我想做的事,但在Android上我是新來的),但是我做了一個popupWindow出現在點擊圖片上,在這裏,我讀了關於如何動畫popupwindow和問題後,我有待辦事項的動畫進入和退出,我想,該怎麼做,但現在我的問題:如何在動畫結束後關閉popupWindow
我不知道該怎麼辦在輸入動畫結束後,popupwindow關閉。
popupWindow代碼:
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View viewAnimationResourceEarned = inflater.inflate(R.layout.layout_animation_resources_earned, null);
animationResourceEarned = new PopupWindow(viewAnimationResourceEarned, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
animationResourceEarned.setAnimationStyle(R.style.styleAnimationResourceEarned);
animationResourceEarned.showAtLocation(viewAnimationResourceEarned, Gravity.CENTER, 0, 0);
輸入動畫代碼:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<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" />
<translate
android:fromYDelta="0"
android:toYDelta="-50"
android:duration="2500"/>
</set>
我要取消的進入動畫結束後,在彈出的窗口,我的目標是popupappear,移動到頂部痘痘和diseppear
我把 「動漫動畫=新的動畫(0,R.style.styleAnimationResourceEarned);」在我的代碼上,但動畫是抽象的;無法實例化 – BrunoM24
我犯了一個錯誤。我編輯了我的答案。請立即檢查。 –
不工作,因爲「styleAnimationResourceEarned」不是資源類型動畫,我嘗試加載進入的動畫,但在popupWindow中導致我需要設置動畫風格,偵聽器不檢測動畫 – BrunoM24