title: How to wrap height of Android ViewPager2 to height of current item?
body: <p>This question is for the new <strong>ViewPager2</strong> class.</p>
  
  <p>There is a <a href="https://stackoverflow.com/questions/34484833/how-to-wrap-the-height-of-a-viewpager-to-the-height-of-its-current-fragment">similar question for the old ViewPager</a>, but the solution requires extending <strong>ViewPager</strong>. However, ViewPager2 is final so cannot be extended.</p>
  
  <p>In my situation, I have a ViewPager2 that contains three different fragments. One of these fragments is much taller than the other two, which means when you swipe to one of the shorter fragments, there is a lot of empty space. So how do I effectively wrap the ViewPager2 to the height of the current fragment?</p>