Can I change the Android startActivity() transition animation?

后端 未结 10 1689
臣服心动
臣服心动 2020-11-28 19:53

I am starting an activity and would rather have a alpha fade-in for startActivity(), and a fade-out for the finish(). How can I go about this in th

10条回答
  •  孤独总比滥情好
    2020-11-28 20:09

    If you always want to the same transition animation for the activity

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    
    @Override
    protected void onPause() {
        super.onPause();
        if (isFinishing()) {
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
    }
    

提交回复
热议问题