title: Pages must fill the whole ViewPager2 (use match_parent) while i set it to match parent
body: <p>I use <code>viewPager2</code> in my app with <code>custom adapter</code> and in layout i use my <code>viewpager2</code> in <code>linearLayout</code>.
  i set the <code>height</code> and <code>width</code> of my <code>viewpager2</code> to <code>matchParent</code>, and i also set it to <code>matchParent</code> in java code, and set <code>attachToRoot</code> to <code>false</code>, but i still get this error when i lunch my app.
  how can i solve this problem?</p>
  <p>this is my layout:</p>
  <pre><code>&lt;LinearLayout
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;View
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_weight=&quot;1&quot; /&gt;
  
      &lt;androidx.viewpager2.widget.ViewPager2
          android:id=&quot;@+id/vp_home&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_weight=&quot;0.7&quot;
          android:clipToPadding=&quot;false&quot;
          android:paddingStart=&quot;20dp&quot;
          android:paddingEnd=&quot;20dp&quot;/&gt;
  
      &lt;View
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_weight=&quot;1&quot; /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>this is my viewpager2 code:</p>
  <pre><code>mAdapter = new adapter_vp2_home(getActivity(), ls);
  
      vp_home.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
      vp_home.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
  
      vp_home.setAdapter(mAdapter);
  </code></pre>
  <p>and this is the log:</p>
  <pre><code>java.lang.IllegalStateException: Pages must fill the whole ViewPager2 (use match_parent)
          at androidx.viewpager2.widget.ViewPager2$4.onChildViewAttachedToWindow(ViewPager2.java:270)
          at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7713)
          at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:857)
          at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
          at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8753)
          at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8711)
          at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8699)
          at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1645)
          at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
          at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668)
          at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4141)
          at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3853)
          at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4410)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:526)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
          at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
          at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1855)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
          at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
          at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
          at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
          at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
          at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
          at com.android.internal.policy.DecorView.onLayout(DecorView.java:945)
          at android.view.View.layout(View.java:20857)
          at android.view.ViewGroup.layout(ViewGroup.java:6401)
          at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2961)
  E/AndroidRuntime:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2648)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1785)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7832)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
          at android.view.Choreographer.doCallbacks(Choreographer.java:723)
          at android.view.Choreographer.doFrame(Choreographer.java:658)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
          at android.os.Handler.handleCallback(Handler.java:789)
          at android.os.Handler.dispatchMessage(Handler.java:98)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6944)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
  </code></pre>