Found the solution to this: ViewPager.onMeasure() handles measuring its children, which I wasn't accounting for. I changed my onMeasure implementation to simply pass super.onMeasure() some new MeasureSpecs with the size I calculate, and presto: Great success.
On Friday, October 12, 2012 1:23:23 AM UTC-7, Chris Sarbora wrote: > > I'm trying to develop a ViewPager subclass that, among other things, > limits itself to a specific aspect ratio (2:1 W:H), and accepts a > BaseAdapter instead of only a PagerAdapter. > > I've built a PagerAdapter implementation that can take a BaseAdapter and > translate to/from, without any apparent problems. No leaking, decent view > recycling, etc. > > However, when I implement onMeasure() in the ViewPager subclass so that I > can start toying with settings its size, suddenly the ViewPager starts > "losing" pages. It will continue to scroll back and forth, but the View > returned by the PagerAdapter isn't displayed. I've tried disabling the view > recycling, and tinkering around with various other behaviors, to no avail. > I'm not really sure where to go from here, as I can't figure out how > onMeasure and the Adapter would be remotely related... but it's absolute: > if I use my custom onMeasure, pages get lost. If I comment onMeasure out, > everything works peachy. > > Source is at https://github.com/tophyr/custompager - I'd be indebted to > anyone who takes a peek and gives me some insight as to what's going on. > > Thanks! > Chris > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en