End animation event android

前端 未结 5 961
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 12:34

I have a fadeout animation in a view (which is inside a fragment), and everytime the animation happens, after it finishes the view redraws itself again. I found a work aroun

5条回答
  •  广开言路
    2020-12-05 13:16

    Functionally the same as the accepted answer but in a much more concise way:

    // Add/Remove any animation parameter
    theView.animate()
            .alpha(0)
            .setDuration(2000)
            .withEndAction(new Runnable() {
                @Override
                public void run() {
                    theView.setVisibility(View.GONE);
                }
            });
    

    Enjoy :)

提交回复
热议问题