Shared element activity transition on android 5

前端 未结 12 739
我寻月下人不归
我寻月下人不归 2021-01-30 13:20

I wanted to setup a shared element transition when going from one Activity to another.

The first Activity has a RecyclerView with items. When an item is clicked that it

12条回答
  •  無奈伤痛
    2021-01-30 13:59

    I had this same error, mine was caused by the same reasoning behind hidro's answer but was caused by the keyboard hiding the shared element that the transition was going back to.

    My workaround was to programmatically close the keyboard right before finishing the activity so the shared element on the previous activity isn't obscured.

    View view = this.getCurrentFocus();
    if (view != null) {  
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
    supportFinishAfterTransition();
    

提交回复
热议问题