When you switch the Viewpager, there's a problem with the cotton 5C Viewpager cotton Android
I used the Viewpager dynamic added five view in the list, each view corresponds to a layout file, such as I now in one of the layout of several imageview, and then switch, there will be a very obvious card break. When the number of pictures is small, such as only a imageview, there will be no cotton. How to solve. Kneel and beg the great God. 0 | Browse 293 | Already Collection 1 | Share
4 answers according to the number of praise the wind-2015.08.23 14:51
Analysis of the reasons for cotton:
1, layout reasons: more layout, cumbersome, every time the page loaded, reinitialized layout, waste of time.
2, page caching mechanism: Do not have to Viewpager to initialize the page, you can save the current page and the previous page, the next page, so switch time, there is a process of anticipating ahead.
3, Picture reason: The problem of the description, loading a card when the problem is reduced, may be the picture is too large, large pictures will occupy more memory, there will be a problem.
So, the corresponding solution:
1, simplify the layout, especially to eliminate the use of the layout layer, such as relativelayout.
2, through the Pageradapter setoffscreenpagelimit () method can be set to keep several pages, in general, set to 2.
3, the image compression.
4, recommend the use of fragment, in each page. Fragment has its own clear life cycle, can better control the display of the page.
5, with handler, delay add picture operation.