Delay shared element transition to complete statelist animation

前端 未结 2 896
醉话见心
醉话见心 2021-01-23 08:47

I\'ve been trying out shared element transition on Lollipop. i have a recyclerview which loads some cards and one click the card expands to its details in the next activity.

相关标签:
2条回答
  • 2021-01-23 08:50

    I ended up using a work around, but I still would want to know what is the right way of doing this and therefore leaving the question open.

    The work around I did was 1. remove the state list animator and add that as an animator in the onclick method. 2. Used a Handler to post a delayed call to the activity

    new Handler().postDelayed(new Runnable() {
                          @Override
                          public void run() {
    
                              Intent i=new Intent(SearxhJobs.this,JobsTypes.class);
                              startActivity(i);
                          }
                      }, 200);
    

    P.S- I did end up removing the effect as it was not very intuitive.

    0 讨论(0)
  • 2021-01-23 08:50

    The way that may help some that already have the Transitions setup in Second Activity:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().getSharedElementEnterTransition().setDuration(500);
        getWindow().getSharedElementReturnTransition().setDuration(500)
            .setInterpolator(new DecelerateInterpolator());
    }
    
    0 讨论(0)
提交回复
热议问题