Android: PopupWindow Animation - Need to know when the animation has ended

I have PopupWindowone that uses alpha animation to create a window with window shading.

Usage PopupWindow.setAnimationStyle()works as expected: the popup disappears when displayed.

However, as soon as the popup is displayed (which means the fade animation is complete), I would like to start a new animation.

I tried using the following to get the basic animation that is referenced through setAnimationStyle()and attach to it AnimationListener:

Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.popup_fade_in);
fadeInAnimation.setAnimationListener(new AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
        Log.d(TAG, "fade-in animation START");
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        Log.d(TAG, "fade-in animation END");
        // Kick off the next animation
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }
});

This does not work: none of the methods are AnimationListenerever called.

Does anyone know how to determine when a popup animation has ended?

, , , . , API, , .

!

+3

Source: https://habr.com/ru/post/1795883/


All Articles