Shared elements realize big picture browsing, that is, recycleView to ViewPager shared animation setExitSharedElementCallback (and integrate high imitation WeChat big picture view, drag and drop to exit)

The shared elements realize big picture browsing, and slide the shared items left and right to change.

(And integrate the big picture view of high imitation WeChat Moments, drag and drop to exit. Post at the end of the article)

 

Don't talk nonsense, just go to the picture

1. Slide to change item

 

2. The sliding list is not visible, the list slides down

 

Figure 1 shows the local resource file display. The purpose is to be afraid that the network URL will fail if the time is too long. Figure 2 is the network url. At this time, there will be network problems, the pictures will not be loaded for a while, and there will be a mechanism to delay the loading of the shared animation. At the same time, the blogger also performed operations on the progress of the image loading, which effectively avoided this drawback. If this article is helpful to you, please help star on github.

 

 


Mainly through 2 methods:

1、setExitSharedElementCallback()

2 、 setEnterSharedElementCallback ()

 

 

The shared element animation page can be monitored, the code is as follows

 

getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
        LogUtils.i("共享元素动画的实现", "onTransitionStart");
        
    }

    @Override
    public void onTransitionEnd(Transition transition) {
        LogUtils.i("共享元素动画的实现", "onTransitionEnd");
        
    }

    @Override
    public void onTransitionCancel(Transition transition) {

    }

    @Override
    public void onTransitionPause(Transition transition) {

    }

    @Override
    public void onTransitionResume(Transition transition) {

    }
});

 

 

The following is a big picture of the integrated and optimized high imitation WeChat Moments to view, drag and drop out (thanks to the author here):

 

● Normal display:

 

 

 

 

● Support long picture:

 

 

 

 

● Support gif animation:

 

 

 

● Support video:

 

 

 

● Properly handle the unloaded image:

 

Source download

 

The following is my github address, welcome to star

Your attention is my biggest motivation,

github portal

Guess you like

Origin blog.csdn.net/leol_2/article/details/80198306