Skip to content

rnevet/WCViewPager

Repository files navigation

WCViewPager

Android ViewPager that respects height of wrap_content.

The WrapContentViewPager is an almost in-place replacement for a android.support.v4.view.ViewPager. When used with wrap_content height the WrapContentViewPager will resize to the height of the selected child view and smoothly change its height when ViewPager is Scrolled.

UPDATE BREAKING CHANGE! Support24: As of support library 24 there has been a change in PagerAdapter preventing the posibility to wrap it, in order to use WrapContentViewPager your PagerAdapter needs to implement the ObjectAtPositionInterface or extend the ObjectAtPositionPagerAdapter.

Solution was inspired by answers to this StackOverflow question: http://stackoverflow.com/questions/8394681/android-i-am-unable-to-have-viewpager-wrap-content

This is a work in progress, so there still might be bugs and edge cases not covered. If you find a bug and open an Issue, please provide instructions how to reproduce it.

Including

At the moment the easiest way to include the library is to copy the classes into your project.

The implementation relies the v4 support library ViewPager.

Use

Just like a ViewPager, either in an XML or Code. UPDATE Support24: Your PagerAdapter needs to implement ObjectAtPositionInterface

Sample project

A simple Sample (using TextViews and ImageViews) project is available for reference under app. You can install the APK to see it in action.

License

This project is licensed under the terms of the MIT license.

About

Android ViewPager that respects height of wrap_content

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages