Search This Blog

Monday 28 October 2013

ViewPager android Fact and constraint about offscreen page limit

ViewPager inbuilt swipe animation is very good. ViewPager exist for a reason with HorizontalScrollView(Which scroll the content in same manner but different methodologies). ViewPager used for swiping content on the base of keep ready next content to be swipe. And its whole limitation and strength, which developer feels some times, lie in that.

How many (i.e Minimum and Maximum) page of ViewPager may be preloaded?

setOffscreenPageLimit(1); decide how many page to be preloaded. As i am not sure about what is the maximum limit for it but minimum is 1. setting off screen page limit to 0 does nothing except throwing  warning in LogCat Requested offscreen page limit 0 too small; defaulting to 1Its because ViewPager is based on concept of keep ready next page to be loaded. ViewPager can not the page which not exist still. Android documentation of ViewPager clearly. But most developer feels its not what they required. Then you have option with some work around there but you can not change ViewPager behavior.

Some people argue that they want to load empty instance of fragment as part of child of ViewPager then later on full content. You are free to do  but you will be solely responsible to handle its complications.

onPageListner gives you a way but its bit of tricky to handle.


I absolutely agree with ViewPager's documentation. There must be some content exist before swiping it down. You can use an in out animation if you do not want to customize ViewPager. But being with Adapter, ViewPager allow you to recyling of View

No comments:

Post a Comment

Feedback always help in improvement. If you have any query suggestion feel free to comment and Keep visiting my blog to encourage me to blogging

Android News and source code