Archive | July 2013

Android Mutiple View ViewPager With Centering

There is no real easy way to do this.  A quick hack I came up with was to find the ViewPager source code and go to private void scrollToItem and add the line:

destX = (int) (destX Р(getWidth() Р getWidth()*mAdapter.getPageWidth(mCurItem))/2);

And it will center the current view with whatever you scale factor is in your page adapters overridden getPageWidth.

This probably won’t make any sense but when you use a viewpager normally and want to get the edges of the next and previous image then you’ll know.

Image