ViewPager + PagerAdapter shows blank pages after first two items

后端 未结 1 1591
遇见更好的自我
遇见更好的自我 2020-12-29 15:09

What\'s happening: The first two ViewPager pages loaded nicely (ViewPager automatically loads +-1 from current page). When you scroll past these the next pa

1条回答
  •  生来不讨喜
    2020-12-29 16:05

    Found my problem. In the parent of the parent of my view someone subclassed LinearLayout and overrode requestLayout() without calling super.requestLayout().

    This broke the refreshing of my view hierarchy and prevented onMeasure and onLayout from being called on my ViewPager. Without measuring and laying out the pages they showed up as blank in ViewPager.

    Hope this helps someone else out someday. It sure took me forever to figure out.

    PRO TIP: android-sdk/tools/hierarchyviewer is incredible. Thank you Android team. Everyone should run it at least once, it can be invaluable in debugging and designing anything UI.

    0 讨论(0)
提交回复
热议问题