Set animation listener to Activity animations

后端 未结 4 449
清歌不尽
清歌不尽 2020-12-16 11:42

I am using overridePendingTransition method to perform custom Activity animations.

I would like to know when the animation ends ( a callback/listener )

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 12:30

    @Hambug solution is nice. But there is problem. onEnterAnimationComplete will work on Lollipop and above API (21).

    @Override
    public void onEnterAnimationComplete() {
        super.onEnterAnimationComplete();
        //write code here.
     }
    

    whatever code you write in above method, won't execute on prelolipop devices. So you should put a version check and write it according to you need e.g. in onCreate.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
            //write code here.
        }
    

提交回复
热议问题