title: recycler view GridLayoutManager first row is one less than others
body: <p>hi i have a recyclerview with GridLayoutManager  that have 3 cols but in the first row just shows 2 items like this :</p>
  
  <p><a href="https://i.stack.imgur.com/Ekec7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ekec7.jpg" alt="enter image description here"></a></p>
  
  <p>where i was wrong in this codes :</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.support.v4.app.Fragment;
  import android.support.v7.widget.GridLayoutManager;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import com.github.florent37.materialviewpager.MaterialViewPagerHelper;
  import com.github.florent37.materialviewpager.adapter.RecyclerViewMaterialAdapter;
  
  import java.util.ArrayList;
  import java.util.List;
  
  
  public class Main_Recycle6 extends Fragment {
  
      private RecyclerView recyclerView;
      private Main_Recycle_Adapter2 movieRecyclerviewAdapter;
  
      private List&lt;Main&gt; movies;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          return inflater.inflate(R.layout.main_grid4, container, false);
  
  
      }
  
      @Override
      public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
          movies = new ArrayList&lt;&gt;();
  
          recyclerView = (RecyclerView) getView().findViewById(R.id.Recycle1);
          recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
         // recyclerView.setNestedScrollingEnabled(false);
          RecyclerView.LayoutManager layoutManager;
          layoutManager = new GridLayoutManager(getActivity(), 3);
          recyclerView.setLayoutManager(layoutManager);
  
  
          movies = getData();
  
          movieRecyclerviewAdapter = new Main_Recycle_Adapter2 (getActivity(), movies);
          recyclerView.setAdapter(movieRecyclerviewAdapter);
  
  
  
  
          RecyclerViewMaterialAdapter movieRecyclerviewAdapterMaterial = new RecyclerViewMaterialAdapter(movieRecyclerviewAdapter);
  
          // 4. set adapter
          recyclerView.setAdapter(movieRecyclerviewAdapterMaterial);
  
          //5. Register the recyclerview to MaterialViewPager
          MaterialViewPagerHelper.registerRecyclerView(getActivity(), recyclerView, null);
  
      }
  
  
      public static Main_Recycle newInstance() {
          return new Main_Recycle();
      }
  
      private List&lt;Main&gt; getData() {
          List&lt;Main&gt; movies = new ArrayList&lt;&gt;();
  
          String names[] = {                    "آزمون 1",
                  "آزمون 2",
                  .....
  
  
          };
          String logos[] = {"i1",
                  "i2",
                  .....
  
          };
  
          for (int i = 0; i &lt; names.length; i++) {
              Main newMovie = new Main(names[i], logos[i]);
  
              movies.add(newMovie);
          }
  
          return movies;
      }
  </code></pre>
  
  <p>adapter :</p>
  
  <pre><code>    import android.content.Context;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.util.Collections;
  import java.util.List;
  
  public class Main_Recycle_Adapter2 extends RecyclerView.Adapter&lt;Main_Recycle_Adapter2.MovieViewHolder&gt; {
      List&lt;Main&gt; movies = Collections.emptyList();
      LayoutInflater layoutInflater;
      Context context;
  
      public Main_Recycle_Adapter2(Context context, List&lt;Main&gt; movies){
          this.context = context;
          layoutInflater = LayoutInflater.from(context);
          this.movies = movies;
  
  
      }
      //;;;;;;;;;;;;;;
      @Override
      public int getItemCount() {
          return movies.size();
      }
      @Override
      public long getItemId(int position) {
          return position;
  
      }
  
  
      @Override
      public MovieViewHolder onCreateViewHolder(ViewGroup parent, int viewType )
      {
          View row;
  
              row = layoutInflater.inflate(R.layout.gridview_custom_layout, parent, false);
  
  
  
          MovieViewHolder holder = new MovieViewHolder(row);
  
          return holder;
      }
  
  
      @Override
      public void onBindViewHolder(MovieViewHolder holder, int position) {
          Main thisMovie = movies.get(position);
  
  
          holder.tozih.setText(thisMovie.getName());
          holder.tablooo.setImageResource(context.getResources().getIdentifier(thisMovie.getLogo(), "drawable", context.getPackageName()));
      }
  
      public class MovieViewHolder extends RecyclerView.ViewHolder {
  
          private TextView tozih;
  
          private ImageView tablooo;
  
          public MovieViewHolder(View itemView) {
              super(itemView);
  
              tozih = (TextView) itemView.findViewById(R.id.gridview_text);
  
              tablooo = (ImageView) itemView.findViewById(R.id.gridview_image);
          }
      }
  }
  </code></pre>
  
  <p>here is the grid code 
  the recyclerview is in a fragment and the fragment is in another activity</p>
  
  <pre><code>RecyclerView.LayoutManager layoutManager;
              layoutManager = new GridLayoutManager(getActivity(), 3);
              recyclerView.setLayoutManager(layoutManager);
  </code></pre>
  
  <p>thanks in advance</p>