title: How I can create a RecyclerView with fixed size image that wrap contents and image is crop centered
body: <p>this is my desired goal:
  <a href="https://i.stack.imgur.com/WsNCE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WsNCE.jpg" alt="enter image description here"></a>
  I want to show my Grid Items in 3 rows with recyclerview. I also have fixed image size in dp 120dpx120dp. but I want to my grid Items fill all the vertical space so that there is no blank space in recyclerView and. so I used this layout for Items:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"&gt;
  
      &lt;android.support.v7.widget.CardView
          android:id="@+id/view_item"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="5dp"
          android:orientation="vertical"
          app:elevation="10dp"&gt;
  
          &lt;LinearLayout
              android:id="@+id/image_container"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_margin="5dp"
              android:orientation="vertical"&gt;
  
              &lt;ImageView
                  android:id="@+id/icon"
                  android:layout_width="120dp"
                  android:layout_height="120dp"
                  android:scaleType="centerCrop"/&gt;
  
              &lt;ir.per.ttf.PersianTextView
                  android:id="@+id/title"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:ellipsize="end"
                  android:singleLine="true"
                  android:textSize="16sp"/&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/android.support.v7.widget.CardView&gt;
  
  &lt;/LinearLayout
  </code></pre>
  
  <p>></p>
  
  <p>but what I see is like this and the image is not cropped center!</p>
  
  <p><a href="https://i.stack.imgur.com/YZ0cN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YZ0cN.jpg" alt="enter image description here"></a></p>
  
  <p>but by reducing image size to 100dpx100dp my RecyclerView do not fill with Items:</p>
  
  <p><a href="https://i.stack.imgur.com/6fV2k.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6fV2k.jpg" alt="enter image description here"></a></p>
  
  <p>and I can not achieve to my desired view.</p>
  
  <p>this is how I use my Adapter:</p>
  
  <pre><code> GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 3,
                  LinearLayoutManager.VERTICAL, false);
          gridLayoutManager.setReverseLayout(true);
          holder.horizonrtalItemRecyclerView.setLayoutManager(gridLayoutManager);
          RecyclerChambersAdapter recyclerAdapter = new RecyclerChambersAdapter(context, items.get(position),3); //pass context, Items and showing count
          holder.horizonrtalItemRecyclerView.setAdapter(recyclerAdapter);
  </code></pre>
  
  <p>and this is onBind view holder:</p>
  
  <pre><code> @Override
      public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
          RecyclerChambersItemViewHolder holder = (RecyclerChambersItemViewHolder) viewHolder;
          try {
  
              holder.setmyClass(myClasses.get(position));
              holder.setTitle(myClasses.get(position).getName());
              holder.setId(myClasses.get(position).getId());
              holder.setItemImageSrc(myClasses.get(position).getPhoto().getUrl().toString());
  
          } catch (Exception ex) {
              holder.setItemImageSrc("");
              ex.printStackTrace();
          }
  
      }
  </code></pre>