title: How set dynamic height of fragment contains RecycleView in ViewPager android?
body: <p>I got help from <a href="https://stackoverflow.com/a/54399123/10699119">links</a> and other links but it didn't help me and my problem was not solved</p>
  <p><strong>MY PROBLEM:</strong> I have ViewPager with 3 Fragment that 2 of them contain RecycleView with dynamic data!</p>
  <p>Now the ViewPage gets the biggest height !!!! I want to set the height of the fragment as the original size!</p>
  <p><strong>my code:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      style=&quot;@style/CardStyle&quot;
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;com.duolingo.open.rtlviewpager.RtlViewPager
          android:id=&quot;@+id/viewpager&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_marginTop=&quot;@dimen/default_margin_double&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/tab_layout&quot; /&gt;
  
      &lt;com.google.android.material.tabs.TabLayout
          android:id=&quot;@+id/tab_layout&quot;
          style=&quot;@style/TabbedCard&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;@dimen/tabbed_card_tab_layout_height&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:tabGravity=&quot;fill&quot;
          app:tabMode=&quot;scrollable&quot;
          app:tabPaddingTop=&quot;@dimen/default_margin_half&quot;
          app:tabTextAppearance=&quot;@style/investTab&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p><strong>and one of my fragment that contains RecyclerView :</strong></p>
  <pre><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_gravity=&quot;center&quot;
      android:scrollbarStyle=&quot;insideOverlay&quot;
      android:orientation=&quot;vertical&quot;
      tools:context=&quot;.mvvm.screens.investment.view.fragment.tabs.RequestListFragment&quot;&gt;
  
  
   
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_gravity=&quot;center&quot;&gt;
  
          &lt;androidx.recyclerview.widget.RecyclerView
              android:id=&quot;@+id/account_list&quot;
              style=&quot;@style/InvestmentRecyclerView&quot;
              android:scrollbarStyle=&quot;insideOverlay&quot;
              tools:listitem=&quot;@layout/investment_request_item&quot;
              android:paddingBottom=&quot;@dimen/default_margin&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;ProgressBar
              android:id=&quot;@+id/loading&quot;
              style=&quot;?android:attr/progressBarStyle&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:indeterminateTint=&quot;?attr/cardTitle&quot;
              android:visibility=&quot;gone&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
  
          &lt;include
              android:id=&quot;@+id/view_error&quot;
              layout=&quot;@layout/view_error&quot;
              android:visibility=&quot;gone&quot; /&gt;
  
          &lt;include
              android:id=&quot;@+id/view_empty&quot;
              layout=&quot;@layout/no_investment_found&quot;
              android:visibility=&quot;gone&quot; /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>