Blinking screen on image transition between activities

后端 未结 12 2259
温柔的废话
温柔的废话 2020-12-02 07:01

I implemented an image transition between two activities using the new shared elements from lollipop. It\'s working but I get a weird white blinking on the entire screen du

12条回答
  •  天涯浪人
    2020-12-02 07:43

    Elements fade in and out, unless you specify explicitly they are the same on both activities. That includes status and navigation bar.

    In your particular case, I would add the toolbar and these two views to the shared elements list:

    List viewPairs = new ArrayList<>();
    viewPairs.add(Pair.create(findViewById(android.R.id.statusBarBackground), Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME));
    viewPairs.add(Pair.create(findViewById(android.R.id.navigationBarBackground), Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME));
    // Add your views...
    
    Pair[] array = new Pair[viewPairs.size()];
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), viewPairs.toArray(array)).toBundle();
    // ...
    
    ActivityCompat.startActivity(activity, intent, options.toBundle());
    

提交回复
热议问题