title: RecyclerView Item match parent
body: <p>I had multiple Recyclerview in a linearLayout, I need to display only one row not all the rows.
  I tried match-parent but it doesn't work, so can anyone hlep me.</p>
  
  <p>in this example I had 3 recycledView created programmatically. </p>
  
  <p><a href="https://i.stack.imgur.com/1A3QJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1A3QJ.png" alt="enter image description here"></a></p>
  
  <p>And this my card view</p>
  
  <pre><code>    &lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:cardview="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          &gt;
          &lt;ImageView
              android:id="@+id/thumbnail"
              android:layout_width="100dp"
              android:layout_height="80dp"
              android:layout_alignParentLeft="true"
              android:layout_centerVertical="true"
              android:scaleType="centerCrop"
              android:src="@drawable/ic_launcher" /&gt;
          &lt;TextView
              android:id="@+id/title"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_centerVertical="true"
              android:layout_toRightOf="@+id/thumbnail"
              android:maxLines="3"
              android:padding="8dp"
              android:text="test"
              android:textColor="#222"
              android:textSize="15dp" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p><strong>Formule.xml</strong> </p>
  
  <p>my Formule.xml</p>
  
  <pre><code>&lt;FrameLayout
      android:id="@+id/mainmenu"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
  
      android:foreground="@drawable/foreground_shape" &gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
  &lt;LinearLayout
      android:id="@+id/top"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:background="@color/transparentWhite"
      &gt;
      &lt;TextView
      android:id="@+id/textViewCategoryParent"
      android:layout_width="match_parent"
      android:layout_gravity="center"
      android:gravity="center"
      android:layout_height="wrap_content" /&gt;          
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:id="@+id/middle"
      android:orientation="horizontal"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="1"
    /&gt;
  &lt;LinearLayout
      android:id="@+id/bottom"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_weight="1"
      android:background="@color/transparentWhite"
      &gt;
      &lt;LinearLayout
          android:id="@+id/CategoriesGallery"
          android:orientation="horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
    &lt;/LinearLayout&gt;
     &lt;/LinearLayout&gt;
  
      &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>Java Code</strong></p>
  
  <pre><code>public void fillFormules(List&lt;Category&gt; objectsTextToShow)
  {
      MyRecyclerAdapter adapter;
      final LinearLayout layoutItemDetail = (LinearLayout) view.findViewById(R.id.middle);
      LinearLayout relativeLayout = (LinearLayout) view.findViewById(R.id.titles);
  
  
      // Initialize recycler view
      for (int j = 0; j &lt;objectsTextToShow.size() ; j++) {
          LinearLayout parentLayout = new LinearLayout(getActivity());
          parentLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, (float) 1.0));
          parentLayout.setOrientation(LinearLayout.HORIZONTAL);
          RecyclerView mRecyclerView = new RecyclerView(getActivity()); //(RecyclerView) view.findViewById(R.id.recycler_view);
          List&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
          TextView textCat = new TextView(getActivity());
          textCat.setText(Check.Languages(objectsTextToShow.get(j).getName(), LANGUAGE_ID));
          textCat.setTextSize(28);
          textCat.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));
          textCat.setTextColor(colorUtils.TITLE);
          textCat.setGravity(Gravity.CENTER);
  
          relativeLayout.addView(textCat);
          textCat.setBackgroundColor(colorUtils.backgroundColor);
  
          for (int i = 0; i &lt;objectsTextToShow.get(j).getItems().size() ; i++) {
              items.add(objectsTextToShow.get(j).getItems().get(i));
          }
          final LinearLayoutManager manager = new LinearLayoutManager(getActivity());
  
          adapter = new MyRecyclerAdapter(getActivity(), items);
          mRecyclerView.setAdapter(adapter);
          parentLayout.addView(mRecyclerView);
          layoutItemDetail.addView(parentLayout);
  
          mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
  
              @Override
              public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                  super.onScrolled(recyclerView, dx, dy);
                  final int Height = layoutItemDetail.getHeight();
                  if(dy &gt; 0){
                      Log.e("RecyclerView scrolled: ", "scroll up!"+Height);
                  //  recyclerView.scrollBy(0, Height);
                  }
                  else{
                  //  recyclerView.scrollBy(0, -Height);
                      }
  
                  Log.e("RecyclerView scrolled: ", "scroll down!"+-Height);}
  
          });
  
      }
  
  }
  </code></pre>