title: How to set border for android recyclerview grid layout.
body: <p>I want a view that looks like this , a border without spacing between items. </p>
  
  <p><a href="https://i.stack.imgur.com/vIXy6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vIXy6.png" alt="enter image description here"></a></p>
  
  <p>Currently my view looks like this, i am using a recyclerview with card view layout. </p>
  
  <p><a href="https://i.stack.imgur.com/8Dy4y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8Dy4y.png" alt="enter image description here"></a></p>
  
  <p>below is my code for each individual item</p>
  
  <p>single_item_homepage xml:</p>
  
  <pre><code>&lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="95dp"
  android:layout_height="95dp"
  android:layout_margin="8dp"
  &gt;
  
      &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  
      &lt;ImageView
          android:id="@+id/imageViewCategory"
          android:layout_width="match_parent"
          android:layout_height="75dp"
          /&gt;
  
      &lt;TextView
          android:text="Shirt"
          android:id="@+id/textViewCategory"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:textSize="15sp"/&gt;
  
  
      &lt;/LinearLayout&gt;
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>HomePage activity:</p>
  
  <pre><code>public class HomepageActivity extends AppCompatActivity {
  
  
  private RecyclerView recyclerView;
  private ImageAdapter imageAdapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_homepage);
  
      recyclerView = findViewById(R.id.recyclerView);
      imageAdapter = new ImageAdapter(this);
  
      recyclerView.setHasFixedSize(true);
      recyclerView.setLayoutManager(new GridLayoutManager(HomepageActivity.this,3));
      recyclerView.setAdapter(imageAdapter);
  
      }
  }
  </code></pre>
  
  <p>this is my adapter class:</p>
  
  <pre><code>public class ImageAdapter extends RecyclerView.Adapter&lt;ImageAdapter.ImageViewHolder&gt; {
  
  
  private Context context;
  
  public ImageAdapter(Context context) {
      this.context = context;
  }
  
  private int[] resourceId = new int[] {R.drawable.shirt,R.drawable.sleeveless,R.drawable.outerwear,
          R.drawable.sweater,R.drawable.pants,R.drawable.shorts,R.drawable.skirt,R.drawable.dresses,
          R.drawable.shoes,R.drawable.bags,R.drawable.accessories,R.drawable.swimwear
  };
  
  private String[] names = new String[]{
          "Shirts","Sleevless","Outerwear","Sweater","Pants","Shorts","Skirts","Dresses","Shoes","Bags","Accessories","Swimwear"
  };
  
  
  
  @NonNull
  @Override
  public ImageAdapter.ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(context).inflate(R.layout.single_item_homepage,parent,false);
      return new ImageViewHolder(v);
  }
  
  @Override
  public void onBindViewHolder(@NonNull ImageAdapter.ImageViewHolder holder, int position) {
      String currName = names[position];
      int currResource = resourceId[position];
      holder.categoryName.setText(currName);
      holder.categoryImage.setImageResource(currResource);
  
  }
  
  @Override
  public int getItemCount() {
      return names.length;
  }
  
  class ImageViewHolder extends RecyclerView.ViewHolder {
  
      TextView categoryName;
      ImageView categoryImage;
  
  
      public ImageViewHolder(View itemView) {
          super(itemView);
  
          categoryName = itemView.findViewById(R.id.textViewCategory);
          categoryImage = itemView.findViewById(R.id.imageViewCategory);
          }
      }
  }
  </code></pre>
  
  <p>is there a way to change the recyclerview border ? Thanks in advance :)</p>