When you switch Viewpager, there's a problem with the cotton.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.