title: Can someone explain me this behaviour of recycler view?
body: <p>I am learning about recyclerview and was just trying out some example and I came across this...
  When I try to use vertical orientation for my list it works out as desired output is something like this:
  <a href="https://i.stack.imgur.com/uTAF0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uTAF0.png" alt="vertical orientation image"></a></p>
  
  <p>and if I change it to horizontal then my view is something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/hfY1x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hfY1x.png" alt="shows one item at a time"></a></p>
  
  <p>my xml is as shown below</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;FrameLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:background="@color/material100Green"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/rv_numbers"/&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>My mainActivity:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private static final int NUM_LIST_ITEMS = 100;
  
      private GreenAdapter mAdapter;
      private RecyclerView mNumbersList;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
          mNumbersList = (RecyclerView) findViewById(R.id.rv_numbers);
          LinearLayoutManager layoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,true);
          mNumbersList.setLayoutManager(layoutManager);
  
          mNumbersList.setLayoutManager(layoutManager);
  
          mNumbersList.setHasFixedSize(true);
  
          /*
           * The GreenAdapter is responsible for displaying each item in the list.
           */
          mAdapter = new GreenAdapter(NUM_LIST_ITEMS);
  
          mNumbersList.setAdapter(mAdapter);
      }
  }
  </code></pre>
  
  <p>GreenAdapter is as shown below:</p>
  
  <pre><code>public class GreenAdapter extends RecyclerView.Adapter&lt;GreenAdapter.NumberViewHolder&gt; {
  
      private static final String TAG = GreenAdapter.class.getSimpleName();
  
      private int mNumberItems;
  
      public GreenAdapter(int numberOfItems) {
          mNumberItems = numberOfItems;
      }
  
      @Override
      public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
          Context context = viewGroup.getContext();
          int layoutIdForListItem = R.layout.number_list_item;
          LayoutInflater inflater = LayoutInflater.from(context);
          boolean shouldAttachToParentImmediately = false;
  
          View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately);
          NumberViewHolder viewHolder = new NumberViewHolder(view);
  
          return viewHolder;
      }
  
      @Override
      public void onBindViewHolder(NumberViewHolder holder, int position) {
          Log.d(TAG, "#" + position);
          holder.bind(position);
      }
  
      @Override
      public int getItemCount() {
          return mNumberItems;
      }
  
      class NumberViewHolder extends RecyclerView.ViewHolder {
  
  
          TextView listItemNumberView;
  
          public NumberViewHolder(View itemView) {
              super(itemView);
  
              listItemNumberView = (TextView) itemView.findViewById(R.id.tv_item_number);
          }
  
          /**
           * This method will take an integer as input and
           * use that integer to display the appropriate text within a list item.
           * @param listIndex Position of the item in the list
           */
          void bind(int listIndex) {
              listItemNumberView.setText(String.valueOf(listIndex));
          }
      }
  }
  </code></pre>
  
  <p>Can someone explain me the above behavior?
  With that if someone can quote the solution for displaying at least 4-5 items while scrolling horizontally would be appreciated :)</p>
  
  <p>Thanks in advance! </p>