---
title: "Migrating to ViewPager2? Beware This Invisible Layout Bug"
url: https://daily.dev/posts/migrating-to-viewpager2-beware-this-invisible-layout-bug-ujhj6vxd1
source_url: https://www.droidcon.com/2025/12/17/migrating-to-viewpager2-beware-this-invisible-layout-bug/
type: article
source: "droidcon"
published: 2026-01-06T09:54:20.866Z
updated: 2026-01-06T09:54:46.574Z
tags: ["mobile", "android"]
reading_time: 4
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating to ViewPager2? Beware This Invisible Layout Bug

**[droidcon](https://daily.dev/sources/droidcon)** · 4 min read · 1 upvotes · 0 comments

## Summary

ViewPager2 can render blank pages when migrating from ViewPager due to a layout measurement issue. Unlike the original ViewPager, ViewPager2 relies on RecyclerView and requires a measurable height from its parent layout. If the parent uses wrap_content or weak constraints, ViewPager2 gets assigned 0 height, causing fragments not to render. The fix involves ensuring the parent provides measurable dimensions through match_parent, fixed dp values, or proper ConstraintLayout constraints with 0dp. Special considerations apply when nesting inside ScrollView (disable swipe or use fixed height) and ConstraintLayout (use MATCH_CONSTRAINT with proper constraints).

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.droidcon.com/2025/12/17/migrating-to-viewpager2-beware-this-invisible-layout-bug/>

---

Tags: [#mobile](https://daily.dev/tags/mobile), [#android](https://daily.dev/tags/android)

[View this post on daily.dev](https://daily.dev/posts/migrating-to-viewpager2-beware-this-invisible-layout-bug-ujhj6vxd1)
