When you use Viewpager to slide fragment, Viewpager only saves the fragment state on both sides of the current page. This can happen when the Page1 and the Page2 are initialized with an open, and Page3 is initialized when manually switching to Page4, However, the Page1 is destroyed, and Page1 is reinitialized when it switches to Page1. In fact, this is a performance optimization provided by Viewpager, called lazy loading.
However, this situation will cause the layout in the page to be re-created, the state can not be saved, the experience is not smooth, the solution is to set ViewPage cache pages;
Android.support.v4.view.ViewPager
public void setoffscreenpagelimit (int limit)
The limit parameter is the number of ViewPage cache pages, for example, if you have four pages full cache then the limit parameter equals 3.
Switch fragment not recreated in Viewpager-Android